ReactOS  0.4.14-dev-552-g2fad488
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:323
#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:70
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
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  SetTimer(hwndDlg, ID_TIMER, 1000, NULL);
280 
281  /* Set range and current year */
282  SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETRANGE, 0, MAKELONG ((short) 9999, (short) 1900));
283  SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_SETPOS, 0, MAKELONG( (short) st.wYear, 0));
284 
286  break;
287 
288  case WM_TIMER:
290  break;
291 
292  case WM_COMMAND:
293  switch (LOWORD(wParam))
294  {
295  case IDC_MONTHCB:
296  if (HIWORD(wParam) == CBN_SELCHANGE)
297  {
300  (WORD) -1,
302  (WORD) -1);
303  }
304  break;
305  }
306  break;
307 
308  case WM_CTLCOLORSTATIC:
309  if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_YEARTEXT))
311  break;
312 
313  case WM_NOTIFY:
314  {
315  LPNMHDR lpnm = (LPNMHDR)lParam;
316 
317  switch (lpnm->idFrom)
318  {
319  case IDC_YEAR:
320  switch (lpnm->code)
321  {
322  case UDN_DELTAPOS:
323  {
324  SHORT wYear;
325  LPNMUPDOWN updown = (LPNMUPDOWN)lpnm;
326  wYear = (SHORT)SendMessageW(GetDlgItem(hwndDlg, IDC_YEAR), UDM_GETPOS, 0, 0);
327  /* Enable the 'Apply' button */
328  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
331  (WORD) -1,
332  (WORD) -1,
333  (WORD) (wYear + updown->iDelta));
334  }
335  break;
336  }
337  break;
338 
339  case IDC_TIMEPICKER:
340  switch (lpnm->code)
341  {
342  case DTN_DATETIMECHANGE:
343  /* Stop the timer */
344  KillTimer(hwndDlg, ID_TIMER);
345 
346  /* Tell the clock to stop ticking */
348  0, 0);
349 
350  /* Enable the 'Apply' button */
351  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
352  break;
353  }
354  break;
355 
356  case IDC_MONTHCALENDAR:
357  switch (lpnm->code)
358  {
359  case MCCN_SELCHANGE:
360  /* Enable the 'Apply' button */
361  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
362  break;
363 
364  case MCCN_AUTOUPDATE:
365  AutoUpdateMonthCal(hwndDlg,
366  (PNMMCCAUTOUPDATE)lpnm);
367  break;
368  }
369  break;
370 
371  default:
372  switch (lpnm->code)
373  {
374  case PSN_SETACTIVE:
375  SetTimeZoneName(hwndDlg);
376  break;
377 
378  case PSN_APPLY:
379  SetLocalSystemTime(hwndDlg);
380  SetTimer(hwndDlg, ID_TIMER, 1000, NULL);
381 
382  /* Tell the clock to start ticking */
384  0, 0);
385  return TRUE;
386  }
387  break;
388  }
389  }
390  break;
391 
392  case WM_TIMECHANGE:
393  /* FIXME: We don't get this message as we're not a top-level window... */
394  SendMessageW(GetDlgItem(hwndDlg,
396  MCCM_RESET,
397  0,
398  0);
399  break;
400 
401  case WM_DESTROY:
402  KillTimer(hwndDlg, ID_TIMER);
403  break;
404  }
405 
406  return FALSE;
407 }
#define LONG_PTR
Definition: treelist.c:79
#define TRUE
Definition: types.h:120
#define UDM_GETPOS
Definition: commctrl.h:2140
static WNDPROC pOldWndProc
Definition: dateandtime.c:14
#define MCCM_RESET
Definition: timedate.h:72
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
struct _NM_UPDOWN * LPNMUPDOWN
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:62
#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:3134
static VOID SetTimeZoneName(HWND hwnd)
Definition: dateandtime.c:111
#define IDC_YEARTEXT
Definition: resource.h:13
WORD wYear
Definition: winbase.h:877
short SHORT
Definition: pedump.c:59
UINT_PTR idFrom
Definition: winuser.h:3133
#define IDC_MONTHCB
Definition: resource.h:6
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define UDM_SETRANGE
Definition: commctrl.h:2137
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_CLOCKWND
Definition: resource.h:9
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define WM_TIMER
Definition: winuser.h:1724
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:75
static VOID SetLocalSystemTime(HWND hwnd)
Definition: dateandtime.c:76
#define DTM_SETSYSTEMTIME
Definition: commctrl.h:4327
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:2165
#define ID_TIMER
Definition: resource.h:23
#define IDC_YEAR
Definition: resource.h:12
#define WM_COMMAND
Definition: winuser.h:1722
#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:2881
int iDelta
Definition: commctrl.h:2162
HWND WINAPI GetParent(_In_ HWND)
#define GDT_VALID
Definition: commctrl.h:4456
#define IDC_MONTHCALENDAR
Definition: resource.h:8
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define UDM_SETPOS
Definition: commctrl.h:2139
#define CBN_SELCHANGE
Definition: winuser.h:1961
static VOID FillMonthsComboBox(HWND hCombo)
Definition: dateandtime.c:146
#define HIWORD(l)
Definition: typedefs.h:246
#define CLM_STOPCLOCK
Definition: timedate.h:62
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define CLM_STARTCLOCK
Definition: timedate.h:63
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define DTN_DATETIMECHANGE
Definition: commctrl.h:4362
static VOID AutoUpdateMonthCal(HWND hwndDlg, PNMMCCAUTOUPDATE lpAutoUpdate)
Definition: dateandtime.c:234
#define WM_INITDIALOG
Definition: winuser.h:1721
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:86
static INT_PTR CALLBACK DTPProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dateandtime.c:246
#define WM_TIMECHANGE
Definition: winuser.h:1616

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:2199
WPARAM wParam
Definition: combotst.c:138
#define WM_KEYDOWN
Definition: winuser.h:1697
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define ID_TIMER
Definition: resource.h:23
#define VK_RIGHT
Definition: winuser.h:2201
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:1948
WORD wMonth
Definition: winbase.h:878
#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:56
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
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
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CB_SETCURSEL
Definition: winuser.h:1943
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:1932
#define INT
Definition: polytest.cpp:20
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1925
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
#define CB_ERR
Definition: winuser.h:2410
unsigned short WORD
Definition: ntddk_ex.h:93
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:72
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:4326
#define GDT_VALID
Definition: commctrl.h:4456
#define IDC_MONTHCALENDAR
Definition: resource.h:8
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MCCM_GETDATE
Definition: timedate.h:71
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define HWND_BROADCAST
Definition: winuser.h:1190
static PLARGE_INTEGER Time
Definition: time.c:105
#define WM_TIMECHANGE
Definition: winuser.h:1616

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:1599
#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:1170
#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:1167

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:406
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:969
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SE_SYSTEMTIME_NAME
Definition: winnt_old.h:376
smooth NULL
Definition: ftsmooth.c:416
#define TOKEN_QUERY
Definition: setypes.h:874
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
BOOL WINAPI SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime)
Definition: time.c:356
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876

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().