CNetworkTime::SetTime Method  
 
BOOL SetTime(
  ULONGLONG ulNetworkTime  
);
BOOL SetTime(
  LPSYSTEMTIME lpSystemTime  
);

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

Parameters

ulNetworkTime
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 SetTime method updates the local system clock to the specified date and time. The user must have the appropriate privileges to change the system clock, otherwise an error will be returned. This typically requires the application to execute with elevated privileges. Because Windows systems are usually configured to automatically synchronize the system clock with a time server using the Windows Time service (W32Time), most applications should not use this function.

It is important to note that the network time value is not the same as the UNIX time value used with the standard C runtime library. The time() function returns the number of seconds since January 1, 1970 which is commonly referred to as the UNIX epoch.

Requirements

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

See Also