From ab8a344656301038f22c67593af7a2dce1888134 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sun, 9 Jul 2006 16:19:39 +0000 Subject: [PATCH] check reg for NTP setting fix a few typos and msvc warnings svn path=/trunk/; revision=22972 --- reactos/dll/cpl/timedate/internettime.c | 52 ++++++++++++++++++++++--- reactos/dll/cpl/timedate/monthcal.c | 16 ++++---- reactos/dll/cpl/timedate/timezone.c | 5 ++- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/reactos/dll/cpl/timedate/internettime.c b/reactos/dll/cpl/timedate/internettime.c index 68bda49b983..a246e965c3c 100644 --- a/reactos/dll/cpl/timedate/internettime.c +++ b/reactos/dll/cpl/timedate/internettime.c @@ -216,7 +216,7 @@ GetNTPServerAddress(LPSTR* lpAddress) } RegCloseKey(hKey); - HeapFree(GetProcessHeap, + HeapFree(GetProcessHeap(), 0, buf); @@ -225,8 +225,8 @@ GetNTPServerAddress(LPSTR* lpAddress) fail: GetError(); if (hKey) RegCloseKey(hKey); - HeapFree(GetProcessHeap, 0, buf); - HeapFree(GetProcessHeap, 0, *lpAddress); + HeapFree(GetProcessHeap(), 0, buf); + HeapFree(GetProcessHeap(), 0, *lpAddress); return FALSE; } @@ -326,11 +326,53 @@ EnableDialogText(HWND hwnd) } +static VOID +GetSyncSetting(HWND hwnd) +{ + HKEY hKey; + HWND hCheck; + LONG Ret; + WCHAR Data[8]; + DWORD Size; + + Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Parameters", + 0, + KEY_QUERY_VALUE, + &hKey); + if (Ret != ERROR_SUCCESS) + { + GetError(); + return; + } + + Size = sizeof(Data); + Ret = RegQueryValueExW(hKey, + L"Type", + NULL, + NULL, + (LPBYTE)Data, + &Size); + if (Ret != ERROR_SUCCESS) + { + GetError(); + } + + if (lstrcmp(Data, L"NTP") == 0) + { + hCheck = GetDlgItem(hwnd, IDC_AUTOSYNC); + SendMessageW(hCheck, BM_SETCHECK, 0, 0); + } + + RegCloseKey(hKey); +} + + static VOID InitialiseDialog(HWND hwnd) { - //check registry if button should be checked - //set button + GetSyncSetting(hwnd); + EnableDialogText(hwnd); CreateNTPServerList(hwnd); diff --git a/reactos/dll/cpl/timedate/monthcal.c b/reactos/dll/cpl/timedate/monthcal.c index a226dc4f3f3..f4081f6beaa 100644 --- a/reactos/dll/cpl/timedate/monthcal.c +++ b/reactos/dll/cpl/timedate/monthcal.c @@ -237,11 +237,11 @@ MonthCalReload(IN PMONTHCALWND infoPtr) TCHAR szBuf[64]; UINT i; - infoPtr->UIState = (DWORD) SendMessage(GetAncestor(infoPtr->hSelf, - GA_PARENT), - WM_QUERYUISTATE, - 0, - 0); + infoPtr->UIState = (DWORD)SendMessage(GetAncestor(infoPtr->hSelf, + GA_PARENT), + WM_QUERYUISTATE, + 0, + 0); /* cache the configuration */ infoPtr->FirstDayOfWeek = MonthCalFirstDayOfWeek(); @@ -631,8 +631,8 @@ MonthCalChangeFont(IN PMONTHCALWND infoPtr, static WORD MonthCalPtToDay(IN PMONTHCALWND infoPtr, - IN SHORT x, - IN SHORT y) + IN INT x, + IN INT y) { WORD Ret = 0; @@ -1017,7 +1017,7 @@ MonthCalWndProc(IN HWND hwnd, SetWindowLongPtr(hwnd, 0, - (DWORD_PTR)infoPtr); + (LONG_PTR)infoPtr); ZeroMemory(infoPtr, sizeof(MONTHCALWND)); diff --git a/reactos/dll/cpl/timedate/timezone.c b/reactos/dll/cpl/timedate/timezone.c index 21fe01db8ec..eb985d070d3 100644 --- a/reactos/dll/cpl/timedate/timezone.c +++ b/reactos/dll/cpl/timedate/timezone.c @@ -289,7 +289,7 @@ SetLocalTimeZone(HWND hwnd) while (i < dwIndex) { if (Entry == NULL) - return; + return; i++; Entry = Entry->Next; @@ -328,6 +328,9 @@ GetAutoDaylightInfo(HWND hwnd) &hKey)) return; + /* if the call fails (non zero), the reg value isn't available, + * which means it shouldn't be disabled, so we should check the button. + */ if (RegQueryValueExW(hKey, L"DisableAutoDaylightTimeSet", NULL,