SetSystemTime

  BOOL SetSystemTime(lpst)    
  LPSYSTEMTIME lpst; /* address of system time to set */

The SetSystemTime function sets the current system time and date.

Parameters

lpst

Points to a SYSTEMTIME structure that contains the current system date and time. The SYSTEMTIME structure has the following form:

typedef struct _SYSTEMTIME { /* st */

WORD wYear;

WORD wMonth;

WORD wDayOfWeek;

WORD wDay;

WORD wHour;

WORD wMinute;

WORD wSecond;

WORD wMilliseconds;

} SYSTEMTIME;

typedef SYSTEMTIME *PSYSTEMTIME, *LPSYSTEMTIME;

The wDayOfWeek member of the SYSTEMTIME structure is ignored.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The application must have SeSystemTimePrivilege for this function to succeed. This privilege is disabled by default. Use the AdjustTokenPrivileges function to enable this privilege, and disable it after the time has been set.

See Also

GetSystemTime, AdjustTokenPrivileges