#include "timedate.h"
#include <stdlib.h>
Go to the source code of this file.
◆ CreateNTPServerList()
static VOID CreateNTPServerList |
( |
HWND |
hwnd | ) |
|
|
static |
Definition at line 17 of file internettime.c.
18{
28
31
33 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
34 0,
38 return;
39
41 {
45 dwIndex,
46 szValName,
47 &dwValSize,
51 &dwNameSize);
53 {
54
55 if (
wcscmp(szValName,
L"") == 0)
56 {
57 dwDefault =
_wtoi(szData);
58 dwIndex++;
59 }
60 else
61 {
64 0,
66 dwIndex++;
67 }
68 }
70 {
71 break;
72 }
73 }
74
75 if (dwDefault < 1 || dwDefault > dwIndex)
76 dwDefault = 1;
77
78
79
80 dwDefault--;
81
84 dwDefault,
85 0);
86
88}
#define RegCloseKey(hKey)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define HKEY_LOCAL_MACHINE
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Referenced by OnInitDialog().
◆ EnableDialogText()
static VOID EnableDialogText |
( |
HWND |
hwnd | ) |
|
|
static |
Definition at line 175 of file internettime.c.
176{
179
182
188}
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
Referenced by InetTimePageProc(), and OnInitDialog().
◆ GetSyncSetting()
Definition at line 269 of file internettime.c.
270{
274
276 L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters",
277 0,
280 {
288 {
289 if (
wcscmp(szData,
L"NTP") == 0)
291 else
293 }
294
296 }
297}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Referenced by OnInitDialog().
◆ InetTimePageProc()
Definition at line 381 of file internettime.c.
385{
386 switch (uMsg)
387 {
390 break;
391
394 {
397 break;
398
401 {
402
404 }
405 break;
406
409 {
411
412
414 }
415 break;
416 }
417 break;
418
420 break;
421
423 {
425
427 {
430
433 else
435
437
438 default:
439 break;
440 }
441 }
442 break;
443 }
444
446}
static VOID EnableDialogText(HWND hwnd)
static VOID OnAutoSync(BOOL Sync)
static VOID OnInitDialog(HWND hwnd)
static VOID OnUpdate(HWND hwndDlg)
static VOID SetNTPServer(HWND hwnd, BOOL bBeginUpdate)
#define PropSheet_Changed(d, w)
struct tagNMHDR * LPNMHDR
HWND WINAPI GetParent(_In_ HWND)
Referenced by Applet().
◆ OnAutoSync()
Definition at line 311 of file internettime.c.
312{
316
317 if (Sync)
319 else
321
323 L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters",
324 0,
328 {
330 return;
331 }
332
335 0,
341
343}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID DisplayWin32Error(DWORD dwErrorCode)
Referenced by InetTimePageProc().
◆ OnInitDialog()
Definition at line 301 of file internettime.c.
302{
308}
static VOID GetSyncSetting(HWND hwnd)
static VOID CreateNTPServerList(HWND hwnd)
static VOID SyncNTPStatusInit(HWND hwnd)
Referenced by InetTimePageProc().
◆ OnUpdate()
Definition at line 364 of file internettime.c.
366{
368 {
370
372 {
375 }
376 }
377}
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
static DWORD WINAPI UpdateThread(_In_ LPVOID lpParameter)
static VOID UpdateNTPStatus(HWND hwnd, DWORD dwReason)
DWORD WINAPI GetLastError(void)
Referenced by InetTimePageProc().
◆ SetNTPServer()
Definition at line 93 of file internettime.c.
94{
102
105
107
109
110
111 if (bBeginUpdate)
112 {
113
116 }
117
118
119
120
121 if (uSel == -1)
122 {
124 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
125 0,
129 {
131 return;
132 }
135 0,
141 }
142
143
144
145 uSel++;
146
147
148 _itow(uSel, szSel, 10);
149
151 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
152 0,
156 {
158 return;
159 }
160
163 0,
169
171}
_CRTIMP wchar_t *__cdecl _itow(_In_ int _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
WCHAR szSyncWait[BUFSIZE]
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
Referenced by InetTimePageProc(), and UpdateThread().
◆ SyncNTPStatusInit()
static VOID SyncNTPStatusInit |
( |
HWND |
hwnd | ) |
|
|
static |
Definition at line 191 of file internettime.c.
192{
193
199
200
201
202
203
204
206}
#define IDS_INETTIMESYNCING
#define IDS_INETTIMEWELCOME
#define IDS_INETTIMEERROR
#define IDS_INETTIMESUCSYNC
#define IDS_INETTIMESUCFILL
WCHAR szSyncInit[BUFSIZE]
WCHAR szSyncType[BUFSIZE]
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
Referenced by OnInitDialog().
◆ UpdateNTPStatus()
Definition at line 209 of file internettime.c.
210{
216
217
220
221
223 {
224
226 {
227
232 szLocalDate,
234
235
240 szLocalTime,
242
243
246 break;
247 }
248
249
251 {
253 DPRINT(
"UpdateNTPStatus(): The user didn't submit any NTP server name!\n");
254 break;
255 }
256
257
258 default:
259 {
262 DPRINT(
"UpdateNTPStatus(): Failed to synchronize the time! (Error: %lu).\n",
dwReason);
263 break;
264 }
265 }
266}
#define LOCALE_USER_DEFAULT
#define ERROR_INVALID_DATA
Referenced by OnUpdate(), and UpdateThread().
◆ UpdateThread()
Definition at line 346 of file internettime.c.
348{
351
352 hwndDlg = (
HWND)lpParameter;
353
355
358
360 return 0;
361}
DWORD WINAPI W32TimeSyncNow(LPCWSTR cmdline, UINT blocking, UINT flags)
Referenced by OnUpdate().
◆ W32TimeSyncNow()
Definition at line 360 of file w32time.c.
363{
367 {
368 DPRINT(
"W32TimeSyncNow failed and clock not set.\n");
369 }
370 else
371 {
372 DPRINT(
"W32TimeSyncNow succeeded and clock set.\n");
373 }
375}
Referenced by UpdateThread().
◆ SyncStatus