ReactOS  0.4.15-dev-3302-ga37d9a4
dateandtime.c File Reference
#include "timedate.h"
Include dependency graph for dateandtime.c:

Go to the source code of this file.

Functions

BOOL SystemSetLocalTime (LPSYSTEMTIME lpSystemTime)
 
static VOID SetLocalSystemTime (HWND hwnd)
 
static VOID SetTimeZoneName (HWND hwnd)
 
static VOID FillMonthsComboBox (HWND hCombo)
 
static WORD GetCBSelectedMonth (HWND hCombo)
 
static VOID ChangeMonthCalDate (HWND hMonthCal, WORD Day, WORD Month, WORD Year)
 
static VOID AutoUpdateMonthCal (HWND hwndDlg, PNMMCCAUTOUPDATE lpAutoUpdate)
 
static INT_PTR CALLBACK DTPProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK DateTimePageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static WNDPROC pOldWndProc = NULL
 

Function Documentation

◆ AutoUpdateMonthCal()

static VOID AutoUpdateMonthCal ( HWND  hwndDlg,
PNMMCCAUTOUPDATE  lpAutoUpdate 
)
static

Definition at line 234 of file dateandtime.c.

236 {
237  UNREFERENCED_PARAMETER(lpAutoUpdate);
238 
239  /* Update the controls */
241  IDC_MONTHCB));
242 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IDC_MONTHCB
Definition: resource.h:6
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static VOID FillMonthsComboBox(HWND hCombo)
Definition: dateandtime.c:146

Referenced by DateTimePageProc().

◆ ChangeMonthCalDate()

static VOID ChangeMonthCalDate ( HWND  hMonthCal,
WORD  Day,
WORD  Month,
WORD  Year 
)
static

Definition at line 220 of file dateandtime.c.

224 {
225  SendMessageW(hMonthCal,
226  MCCM_SETDATE,
227  MAKEWPARAM(Day,
228  Month),
229  MAKELPARAM(Year,
230  0));
231 }
#define MCCM_SETDATE
Definition: timedate.h:81
#define MAKEWPARAM(l, h)
Definition: winuser.h:3985
#define MAKELPARAM(l, h)
Definition: winuser.h:3984
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DateTimePageProc().

◆ DateTimePageProc()

INT_PTR CALLBACK DateTimePageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 265 of file dateandtime.c.

269 {
270  SYSTEMTIME st;
271  GetLocalTime(&st);
272 
273  switch (uMsg)
274  {
275  case WM_INITDIALOG:
277  IDC_MONTHCB));
278 
279  /* Set range and current year */
280  SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETRANGE, 0, MAKELONG ((short) 9999, (short) 1900));
281  SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETPOS, 0, MAKELONG( (short) st.wYear, 0));
282 
284 
285  SetTimer(hwndDlg, ID_TIMER, 1000 - st.wMilliseconds, NULL);
286  break;
287 
288  case WM_TIMER:
290 
291  // Reset timeout.
292  SetTimer(hwndDlg, ID_TIMER, 1000 - st.wMilliseconds, NULL);
293  break;
294 
295  case WM_COMMAND:
296  switch (LOWORD(wParam))
297  {
298  case IDC_MONTHCB:
299  if (HIWORD(wParam) == CBN_SELCHANGE)
300  {
303  (WORD) -1,
305  (WORD) -1);
306  }
307  break;
308  }
309  break;
310 
311  case WM_CTLCOLORSTATIC:
312  if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_YEARTEXT))
314  break;
315 
316  case WM_NOTIFY:
317  {
318  LPNMHDR lpnm = (LPNMHDR)lParam;
319 
320  switch (lpnm->idFrom)
321  {
322  case IDC_YEAR:
323  switch (lpnm->code)
324  {
325  case UDN_DELTAPOS:
326  {
327  SHORT wYear;
328  LPNMUPDOWN updown = (LPNMUPDOWN)lpnm;
329  wYear = (SHORT)SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_GETPOS, 0, 0);
330  /* Enable the 'Apply' button */
331  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
334  (WORD) -1,
335  (WORD) -1,
336  (WORD) (wYear + updown->iDelta));
337  }
338  break;
339  }
340  break;
341 
342  case IDC_TIMEPICKER:
343  switch (lpnm->code)
344  {
345  case DTN_DATETIMECHANGE:
346  /* Stop the timer */
347  KillTimer(hwndDlg, ID_TIMER);
348 
349  /* Tell the clock to stop ticking */
351  0, 0);
352 
353  // TODO: Set the clock to the input time.
354 
355  /* Enable the 'Apply' button */
356  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
357  break;
358  }
359  break;
360 
361  case IDC_MONTHCALENDAR:
362  switch (lpnm->code)
363  {
364  case MCCN_SELCHANGE:
365  /* Enable the 'Apply' button */
366  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
367  break;
368 
369  case MCCN_AUTOUPDATE:
370  AutoUpdateMonthCal(hwndDlg,
371  (PNMMCCAUTOUPDATE)lpnm);
372  break;
373  }
374  break;
375 
376  default:
377  switch (lpnm->code)
378  {
379  case PSN_SETACTIVE:
380  SetTimeZoneName(hwndDlg);
381  break;
382 
383  case PSN_APPLY:
384  SetLocalSystemTime(hwndDlg);
385 
386  /* Tell the clock to start ticking */
388  0, 0);
389 
390  SetTimer(hwndDlg, ID_TIMER, 1000 - st.wMilliseconds, NULL);
391  return TRUE;
392  }
393  break;
394  }
395  }
396  break;
397 
398  case WM_TIMECHANGE:
399  /* FIXME: We don't get this message as we're not a top-level window... */
400  SendMessageW(GetDlgItem(hwndDlg,
402  MCCM_RESET,
403  0,
404  0);
405  break;
406 
407  case WM_DESTROY:
408  KillTimer(hwndDlg, ID_TIMER);
409  break;
410  }
411 
412  return FALSE;
413 }
#define LONG_PTR
Definition: treelist.c:79
#define UDM_GETPOS
Definition: commctrl.h:2144
#define TRUE
Definition: types.h:120
static WNDPROC pOldWndProc
Definition: dateandtime.c:14
#define MCCM_RESET
Definition: timedate.h:83
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1755
struct _NM_UPDOWN * LPNMUPDOWN
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:64
#define PSN_SETACTIVE
Definition: prsht.h:115
#define COLOR_WINDOW
Definition: winuser.h:908
WPARAM wParam
Definition: combotst.c:138
#define IDC_TIMEPICKER
Definition: resource.h:11
struct tagNMHDR * LPNMHDR
UINT code
Definition: winuser.h:3135
static VOID SetTimeZoneName(HWND hwnd)
Definition: dateandtime.c:111
#define IDC_YEARTEXT
Definition: resource.h:13
WORD wYear
Definition: winbase.h:899
#define FALSE
Definition: types.h:117
short SHORT
Definition: pedump.c:59
UINT_PTR idFrom
Definition: winuser.h:3134
#define IDC_MONTHCB
Definition: resource.h:6
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define UDM_SETRANGE
Definition: commctrl.h:2141
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1592
#define IDC_CLOCKWND
Definition: resource.h:9
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define WM_TIMER
Definition: winuser.h:1725
unsigned short WORD
Definition: ntddk_ex.h:93
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MCCN_SELCHANGE
Definition: timedate.h:86
WORD wMilliseconds
Definition: winbase.h:906
static VOID SetLocalSystemTime(HWND hwnd)
Definition: dateandtime.c:76
#define DTM_SETSYSTEMTIME
Definition: commctrl.h:4331
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static VOID ChangeMonthCalDate(HWND hMonthCal, WORD Day, WORD Month, WORD Year)
Definition: dateandtime.c:220
#define UDN_DELTAPOS
Definition: commctrl.h:2169
#define ID_TIMER
Definition: resource.h:23
#define IDC_YEAR
Definition: resource.h:12
#define WM_COMMAND
Definition: winuser.h:1723
#define GWLP_WNDPROC
Definition: treelist.c:66
static WORD GetCBSelectedMonth(HWND hCombo)
Definition: dateandtime.c:195
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2882
int iDelta
Definition: commctrl.h:2166
HWND WINAPI GetParent(_In_ HWND)
#define GDT_VALID
Definition: commctrl.h:4460
#define IDC_MONTHCALENDAR
Definition: resource.h:8
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define UDM_SETPOS
Definition: commctrl.h:2143
#define NULL
Definition: types.h:112
#define CBN_SELCHANGE
Definition: winuser.h:1962
static VOID FillMonthsComboBox(HWND hCombo)
Definition: dateandtime.c:146
#define HIWORD(l)
Definition: typedefs.h:247
#define CLM_STOPCLOCK
Definition: timedate.h:73
#define SetWindowLongPtrW
Definition: winuser.h:5322
#define CLM_STARTCLOCK
Definition: timedate.h:74
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define DTN_DATETIMECHANGE
Definition: commctrl.h:4366
static VOID AutoUpdateMonthCal(HWND hwndDlg, PNMMCCAUTOUPDATE lpAutoUpdate)
Definition: dateandtime.c:234
#define WM_INITDIALOG
Definition: winuser.h:1722
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define MCCN_AUTOUPDATE
Definition: timedate.h:97
static INT_PTR CALLBACK DTPProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dateandtime.c:246
#define WM_TIMECHANGE
Definition: winuser.h:1617

Referenced by Applet().

◆ DTPProc()

static INT_PTR CALLBACK DTPProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 246 of file dateandtime.c.

250 {
251  switch (uMsg)
252  {
253  case WM_KEYDOWN:
254  /* Stop the timer when the user is about to change the time */
255  if ((wParam != VK_LEFT) & (wParam != VK_RIGHT))
257  break;
258  }
259 
260  return CallWindowProcW(pOldWndProc, hwnd, uMsg, wParam, lParam);
261 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static WNDPROC pOldWndProc
Definition: dateandtime.c:14
#define VK_LEFT
Definition: winuser.h:2200
WPARAM wParam
Definition: combotst.c:138
#define WM_KEYDOWN
Definition: winuser.h:1698
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define ID_TIMER
Definition: resource.h:23
#define VK_RIGHT
Definition: winuser.h:2202
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139

Referenced by DateTimePageProc().

◆ FillMonthsComboBox()

static VOID FillMonthsComboBox ( HWND  hCombo)
static

Definition at line 146 of file dateandtime.c.

147 {
148  SYSTEMTIME LocalDate = {0};
149  WCHAR szBuf[64];
150  INT i;
151  UINT Month;
152 
153  GetLocalTime(&LocalDate);
154 
155  SendMessageW(hCombo,
157  0,
158  0);
159 
160  for (Month = 1;
161  Month <= 13;
162  Month++)
163  {
165  ((Month < 13) ? LOCALE_SMONTHNAME1 + Month - 1 : LOCALE_SMONTHNAME13),
166  szBuf,
167  sizeof(szBuf) / sizeof(szBuf[0]));
168  if (i > 1)
169  {
170  i = (INT)SendMessageW(hCombo,
171  CB_ADDSTRING,
172  0,
173  (LPARAM)szBuf);
174  if (i != CB_ERR)
175  {
176  SendMessageW(hCombo,
178  (WPARAM)i,
179  Month);
180 
181  if (Month == (UINT)LocalDate.wMonth)
182  {
183  SendMessageW(hCombo,
184  CB_SETCURSEL,
185  (WPARAM)i,
186  0);
187  }
188  }
189  }
190  }
191 }
#define CB_SETITEMDATA
Definition: winuser.h:1949
WORD wMonth
Definition: winbase.h:900
#define LOCALE_USER_DEFAULT
#define LOCALE_SMONTHNAME13
Definition: winnls.h:103
#define INT
Definition: polytest.cpp:20
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define CB_ADDSTRING
Definition: winuser.h:1919
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define CB_RESETCONTENT
Definition: winuser.h:1942
#define CB_ERR
Definition: winuser.h:2411
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CB_SETCURSEL
Definition: winuser.h:1944
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50

Referenced by AutoUpdateMonthCal(), and DateTimePageProc().

◆ GetCBSelectedMonth()

static WORD GetCBSelectedMonth ( HWND  hCombo)
static

Definition at line 195 of file dateandtime.c.

196 {
197  INT i;
198  WORD Ret = (WORD)-1;
199 
200  i = (INT)SendMessageW(hCombo,
201  CB_GETCURSEL,
202  0,
203  0);
204  if (i != CB_ERR)
205  {
206  i = (INT)SendMessageW(hCombo,
208  (WPARAM)i,
209  0);
210 
211  if (i >= 1 && i <= 13)
212  Ret = (WORD)i;
213  }
214 
215  return Ret;
216 }
#define CB_GETITEMDATA
Definition: winuser.h:1933
#define INT
Definition: polytest.cpp:20
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define CB_GETCURSEL
Definition: winuser.h:1926
#define CB_ERR
Definition: winuser.h:2411
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DateTimePageProc().

◆ SetLocalSystemTime()

static VOID SetLocalSystemTime ( HWND  hwnd)
static

Definition at line 76 of file dateandtime.c.

77 {
79 
82  &Time) == GDT_VALID &&
86  (WPARAM)&Time,
87  0))
88  {
90 
94 
97  MCCM_RESET,
98  (WPARAM)&Time,
99  0);
100 
101  /* Broadcast the time change message */
104  0,
105  0);
106  }
107 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MCCM_RESET
Definition: timedate.h:83
UINT_PTR WPARAM
Definition: windef.h:207
BOOL SystemSetLocalTime(LPSYSTEMTIME lpSystemTime)
Definition: dateandtime.c:17
#define IDC_TIMEPICKER
Definition: resource.h:11
#define DWLP_MSGRESULT
Definition: winuser.h:864
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PSNRET_NOERROR
Definition: prsht.h:129
#define DateTime_GetSystemtime(hdp, pst)
Definition: commctrl.h:4330
#define GDT_VALID
Definition: commctrl.h:4460
#define IDC_MONTHCALENDAR
Definition: resource.h:8
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MCCM_GETDATE
Definition: timedate.h:82
#define SetWindowLongPtrW
Definition: winuser.h:5322
#define HWND_BROADCAST
Definition: winuser.h:1190
static PLARGE_INTEGER Time
Definition: time.c:105
#define WM_TIMECHANGE
Definition: winuser.h:1617

Referenced by DateTimePageProc().

◆ SetTimeZoneName()

static VOID SetTimeZoneName ( HWND  hwnd)
static

Definition at line 111 of file dateandtime.c.

112 {
113  TIME_ZONE_INFORMATION TimeZoneInfo;
114  WCHAR TimeZoneString[128];
115  WCHAR TimeZoneText[128];
116  WCHAR TimeZoneName[128];
117  DWORD TimeZoneId;
118 
119  TimeZoneId = GetTimeZoneInformation(&TimeZoneInfo);
120 
121  LoadStringW(hApplet, IDS_TIMEZONETEXT, TimeZoneText, 128);
122 
123  switch (TimeZoneId)
124  {
127  wcscpy(TimeZoneName, TimeZoneInfo.StandardName);
128  break;
129 
131  wcscpy(TimeZoneName, TimeZoneInfo.DaylightName);
132  break;
133 
135  default:
136  LoadStringW(hApplet, IDS_TIMEZONEINVALID, TimeZoneName, 128);
137  break;
138  }
139 
140  wsprintfW(TimeZoneString, TimeZoneText, TimeZoneName);
141  SendDlgItemMessageW(hwnd, IDC_TIMEZONE, WM_SETTEXT, 0, (LPARAM)TimeZoneString);
142 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
#define TIME_ZONE_ID_UNKNOWN
Definition: rtltypes.h:250
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:283
HINSTANCE hApplet
Definition: access.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1600
#define TIME_ZONE_ID_STANDARD
Definition: rtltypes.h:251
#define IDS_TIMEZONETEXT
Definition: resource.h:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
WCHAR DaylightName[32]
Definition: winbase.h:1192
#define IDC_TIMEZONE
Definition: resource.h:10
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:252
#define IDS_TIMEZONEINVALID
Definition: resource.h:33
WCHAR StandardName[32]
Definition: winbase.h:1189

Referenced by DateTimePageProc().

◆ SystemSetLocalTime()

BOOL SystemSetLocalTime ( LPSYSTEMTIME  lpSystemTime)

Definition at line 17 of file dateandtime.c.

18 {
19  HANDLE hToken;
20  DWORD PrevSize;
21  TOKEN_PRIVILEGES priv, previouspriv;
22  BOOL Ret = FALSE;
23 
24  /*
25  * Enable the SeSystemtimePrivilege privilege
26  */
27 
30  &hToken))
31  {
32  priv.PrivilegeCount = 1;
34 
37  &priv.Privileges[0].Luid))
38  {
39  if (AdjustTokenPrivileges(hToken,
40  FALSE,
41  &priv,
42  sizeof(previouspriv),
43  &previouspriv,
44  &PrevSize) &&
46  {
47  /*
48  * We successfully enabled it, we're permitted to change the time.
49  * Call SetLocalTime twice to ensure correct results.
50  */
51  Ret = SetLocalTime(lpSystemTime) &&
52  SetLocalTime(lpSystemTime);
53 
54  /*
55  * For the sake of security, restore the previous status again
56  */
57  if (previouspriv.PrivilegeCount > 0)
58  {
59  AdjustTokenPrivileges(hToken,
60  FALSE,
61  &previouspriv,
62  0,
63  NULL,
64  0);
65  }
66  }
67  }
68  CloseHandle(hToken);
69  }
70 
71  return Ret;
72 }
#define CloseHandle
Definition: compat.h:598
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
#define ERROR_SUCCESS
Definition: deptool.c:10
$ULONG PrivilegeCount
Definition: setypes.h:988
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SE_SYSTEMTIME_NAME
Definition: winnt_old.h:377
#define TOKEN_QUERY
Definition: setypes.h:893
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetCurrentProcess()
Definition: compat.h:618
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:989
BOOL WINAPI SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime)
Definition: time.c:356
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:895

Referenced by SetLocalSystemTime().

Variable Documentation

◆ pOldWndProc

WNDPROC pOldWndProc = NULL
static

Definition at line 14 of file dateandtime.c.

Referenced by create_treeview_control(), DateTimePageProc(), and DTPProc().