66HINSTANCE hInst;
77static HWND hwndDlg;
88
9- void RestartProgram ()
10- {
11- TCHAR szFileName[MAX_PATH];
12- GetModuleFileName (NULL , szFileName, MAX_PATH);
13-
14- // Cerrar el proceso actual
15- STARTUPINFO si;
16- PROCESS_INFORMATION pi;
17-
18- ZeroMemory (&si, sizeof (si));
19- si.cb = sizeof (si);
20- ZeroMemory (&pi, sizeof (pi));
21-
22- if (!CreateProcess (NULL , szFileName, NULL , NULL , FALSE , 0 , NULL , NULL , &si, &pi))
23- {
24- printf (" Error al reiniciar el programa: %d\n " , GetLastError ());
25- return ;
26- }
27-
28- CloseHandle (pi.hProcess );
29- CloseHandle (pi.hThread );
30-
31- // Obtener el identificador del proceso actual y cerrarlo
32- DWORD currentProcessId = GetCurrentProcessId ();
33- HANDLE currentProcessHandle = OpenProcess (PROCESS_TERMINATE, FALSE , currentProcessId);
34- TerminateProcess (currentProcessHandle, 0 );
35- CloseHandle (currentProcessHandle);
36- }
37-
389// Leer REG_SZ del registro
3910char * RegKeyQueryEx (HKEY hKey, LPCSTR lpSubKey, LPCSTR lpValueName)
4011{
@@ -161,15 +132,14 @@ void _SetProcessInformation()
161132 }
162133}
163134
164- // buffer LTEXT
165- char buffer[21 ];
166-
167135BOOL CALLBACK DlgMain (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
168136{
169137 switch (uMsg)
170138 {
171139 case WM_INITDIALOG:
172140 {
141+
142+
173143 // establecer prioridad de segundo plano (low i/o y low mem priority)
174144 SetPriorityClass (GetCurrentProcess (), PROCESS_MODE_BACKGROUND_BEGIN);
175145
@@ -198,6 +168,9 @@ BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
198168 // Llamar a ZwQueryTimerResolution
199169 _ZwQueryTimerResolution ();
200170
171+ // LTEXT
172+ char buffer[21 ];
173+
201174 // Convertir maxRes a cadena
202175 sprintf (buffer, " Maximun Timer Resolution: %lu ns" , maxRes);
203176 SetDlgItemText (hwndDlg, _MAX, buffer);
@@ -218,7 +191,7 @@ BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
218191 if (custom)
219192 {
220193 SetDlgItemText (hwndDlg, _CUSTOM, f_custom); // rellenar edit con valor obtenido del registro
221- ULONG f_res = strtoul (f_custom, NULL , 0 );
194+ ULONG f_res = strtoul (f_custom, NULL , 10 );
222195 _ZwSetTimerResolution (f_res);
223196 // Convertir actRes a cadena
224197 sprintf (buffer, " Current Timer Resolution: %lu ns" , actRes);
@@ -346,7 +319,7 @@ BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
346319 {
347320 // Obtener texto del EDIT para DesiredResolution
348321 GetDlgItemText (hwndDlg, _CUSTOM, lpbuffer, sizeof (lpbuffer));
349- ULONG lpres = strtoul (lpbuffer, NULL , 0 );
322+ ULONG lpres = strtoul (lpbuffer, NULL , 10 );
350323
351324 // Call ZwSetTimerResolution
352325 _ZwSetTimerResolution (lpres);
@@ -355,7 +328,6 @@ BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
355328 sprintf (buffer, " Current Timer Resolution: %lu ns" , actRes);
356329 SetDlgItemText (hwndDlg, _CURR, buffer);
357330 RegKeySetEx (HKEY_CURRENT_USER, " Software\\ ZwSetTimer" , " CustomTimer" , lpbuffer);
358- RestartProgram ();
359331 }
360332 return TRUE ;
361333
0 commit comments