|
The Time protocol library enables an application to retrieve the
current time from a remote system, and optionally synchronize the
local system time using that value. The first step that your
application must take is to initialize the library. After the
library has been initialized, the application can request the
current time from a system and update the local system clock if
necessary.
TimeInitialize
Initialize the library and load the Windows Sockets library for the
current process. This must be the first function call that the
application makes before calling the other Time API functions.
GetNetworkTime
Return the current time from a remote host. The time is expressed
as a 32-bit integer value which represents the number of seconds
since midnight, 1 January 1900 UTC.
UpdateLocalTime
Update the local system time with the value returned by
GetNetworkTime. On Windows NT and later versions of the operating
system, this function requires that the current user have the
appropriate permissions to modify the system time or the function
will fail.
TimeUninitialize
Unload the Windows Sockets library and release any resources that
have been allocated for the current process. This is the last
function call the application should make prior to terminating.
Time Conversion
Windows applications typically use a structure called SYSTEMTIME to represent
date and time values. The library has two functions which will
enable you to convert between the value returned by GetNetworkTime
and the SYSTEMTIME structure.
ConvertNetworkTime
This function will convert the value returned by GetNetworkTime
into a SYSTEMTIME structure, adjusting for the local timezone if
required.
ConvertSystemTime
This function will convert a SYSTEMTIME structure into a 32-bit
integer value. This value may be passed to the UpdateLocalTime
function to update the local system clock.
|