https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33401f38751656ba93704…
commit 33401f38751656ba93704b2b84edb2a57246c6b0
Author: Doug Lyons <douglyons(a)douglyons.com>
AuthorDate: Sat Apr 21 08:13:27 2018 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun Jul 7 12:45:17 2019 +0200
[TIMEDATE] Use w32time compatible registry settings. CORE-13001
---
dll/cpl/timedate/internettime.c | 46 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/dll/cpl/timedate/internettime.c b/dll/cpl/timedate/internettime.c
index a5f102af35b..81a3ed0791c 100644
--- a/dll/cpl/timedate/internettime.c
+++ b/dll/cpl/timedate/internettime.c
@@ -157,7 +157,7 @@ GetSyncSetting(HWND hwnd)
DWORD dwSize;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
-
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Parameters",
+
L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters",
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
@@ -171,7 +171,9 @@ GetSyncSetting(HWND hwnd)
&dwSize) == ERROR_SUCCESS)
{
if (wcscmp(szData, L"NTP") == 0)
- SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, 0, 0);
+ SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, BST_CHECKED, 0);
+ else
+ SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, BST_UNCHECKED, 0);
}
RegCloseKey(hKey);
@@ -187,6 +189,40 @@ OnInitDialog(HWND hwnd)
CreateNTPServerList(hwnd);
}
+static VOID
+OnAutoSync(BOOL Sync)
+{
+ HKEY hKey;
+ LONG lRet;
+ LPCWSTR szAuto;
+
+ if (Sync)
+ szAuto = L"NTP";
+ else
+ szAuto = L"NoSync";
+
+ lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+
L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters",
+ 0,
+ KEY_SET_VALUE,
+ &hKey);
+ if (lRet != ERROR_SUCCESS)
+ {
+ DisplayWin32Error(lRet);
+ return;
+ }
+
+ lRet = RegSetValueExW(hKey,
+ L"Type",
+ 0,
+ REG_SZ,
+ (LPBYTE)szAuto,
+ (wcslen(szAuto) + 1) * sizeof(WCHAR));
+ if (lRet != ERROR_SUCCESS)
+ DisplayWin32Error(lRet);
+
+ RegCloseKey(hKey);
+}
/* Property page dialog callback */
INT_PTR CALLBACK
@@ -249,6 +285,12 @@ InetTimePageProc(HWND hwndDlg,
{
case PSN_APPLY:
SetNTPServer(hwndDlg);
+
+ if (SendDlgItemMessageW(hwndDlg, IDC_AUTOSYNC, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
+ OnAutoSync(TRUE);
+ else
+ OnAutoSync(FALSE);
+
return TRUE;
default: