CNetworkTime::SetTime Method  
 
BOOL SetTime(
  DWORD dwNetworkTime  
);
BOOL SetTime(
  LPSYSTEMTIME lpSystemTime  
);

The SetTime method sets the local system clock to the specified date and time.

Parameters

dwNetworkTime
The date and time the system clock should be set to, represented as the number of seconds since midnight, 1 January 1900.
lpSystemTime
A pointer to a SYSTEMTIME structure that specifies the date and time that the local clock should be set to.

Return Value

If the method is able to update the local time, it returns a non-zero value. If the specified time is invalid, or the user does not have the access rights to change the system clock, the method returns zero.

Remarks

The network time value is an unsigned 32-bit integer which can represent a date and time up to the year 2036. It is important to note that this is not the same as the UNIX time value which is used by the standard C library.

You must have administrator privileges in order to set the system clock.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cstimv11.lib

See Also

ConvertTime, GetTime