mirror of
https://github.com/reactos/reactos.git
synced 2025-06-22 09:41:27 +00:00
[W32TIME] Remember date/time sync settings (#5866)
Based on KRosUser's patch. - In the W32TmServiceMain function, the time check loop does check the registry value. CORE-19292
This commit is contained in:
parent
eb4d13c823
commit
e627c3b00e
1 changed files with 39 additions and 24 deletions
|
@ -230,8 +230,6 @@ ControlHandler(DWORD request)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,8 +237,12 @@ VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
W32TmServiceMain(DWORD argc, LPWSTR *argv)
|
W32TmServiceMain(DWORD argc, LPWSTR *argv)
|
||||||
{
|
{
|
||||||
int result;
|
LONG error;
|
||||||
DWORD dwInterval;
|
DWORD dwInterval;
|
||||||
|
HKEY hKey;
|
||||||
|
WCHAR szData[8];
|
||||||
|
DWORD cbData;
|
||||||
|
BOOL bNoSync;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(argc);
|
UNREFERENCED_PARAMETER(argc);
|
||||||
UNREFERENCED_PARAMETER(argv);
|
UNREFERENCED_PARAMETER(argv);
|
||||||
|
@ -279,29 +281,44 @@ W32TmServiceMain(DWORD argc, LPWSTR *argv)
|
||||||
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||||
SetServiceStatus(hStatus, &ServiceStatus);
|
SetServiceStatus(hStatus, &ServiceStatus);
|
||||||
|
|
||||||
/* The worker loop of a service */
|
/* The service's worker loop */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
result = SetTime();
|
/* The default is NoSync */
|
||||||
|
bNoSync = TRUE;
|
||||||
|
|
||||||
if (result)
|
/* TODO: Use RegNotifyChangeKeyValue() when implemented */
|
||||||
DPRINT("W32Time Service failed to set clock.\n");
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
else
|
L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters",
|
||||||
DPRINT("W32Time Service successfully set clock.\n");
|
0,
|
||||||
|
KEY_QUERY_VALUE,
|
||||||
if (result)
|
&hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
/* In general we do not want to stop this service for a single
|
cbData = sizeof(szData);
|
||||||
|
RegQueryValueExW(hKey, L"Type", NULL, NULL, (LPBYTE)szData, &cbData);
|
||||||
|
szData[ARRAYSIZE(szData) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
|
||||||
|
bNoSync = (_wcsicmp(szData, L"NoSync") == 0);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bNoSync)
|
||||||
|
{
|
||||||
|
error = SetTime();
|
||||||
|
if (error != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("W32Time Service failed to set clock: 0x%08lX\n", error);
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* In general, we do not want to stop this service for a single
|
||||||
* Internet read failure but there may be other reasons for which
|
* Internet read failure but there may be other reasons for which
|
||||||
* we really might want to stop it.
|
* we really might want to stop it. Therefore this code is left here.
|
||||||
* Therefore this code is left here to make it easy to stop this
|
*/
|
||||||
* service when the correct conditions can be determined, but it
|
|
||||||
* is left commented out.
|
|
||||||
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||||
ServiceStatus.dwWin32ExitCode = result;
|
ServiceStatus.dwWin32ExitCode = error;
|
||||||
SetServiceStatus(hStatus, &ServiceStatus);
|
SetServiceStatus(hStatus, &ServiceStatus);
|
||||||
return;
|
return;
|
||||||
*/
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WaitForSingleObject(hStopEvent, dwInterval * 1000) == WAIT_OBJECT_0)
|
if (WaitForSingleObject(hStopEvent, dwInterval * 1000) == WAIT_OBJECT_0)
|
||||||
|
@ -317,11 +334,9 @@ W32TmServiceMain(DWORD argc, LPWSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
DllMain(HINSTANCE hinstDLL,
|
DllMain(HINSTANCE hinstDLL,
|
||||||
DWORD fdwReason,
|
DWORD fdwReason,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue