SetSystemTime Function

Declare Function SetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME) As Long

Platforms

Description & Usage

SetSystemTime sets the date and time of the system's clock. The time given to the function must be in UTC time (Coordinated Universal Time, a.k.a. Greenwich Mean Time (GMT)), not in the system's local time zone.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

lpSystemTime
The new time and date to use to set the system clock. The wDayOfWeek member of the structure is ignored.

Example

' This code is licensed according to the terms and conditions listed here.

' Set the system clock to the following time:
' October 3, 1999 16:46:00 UTC
Dim systime As SYSTEMTIME  ' new time and date
Dim retval As Long  ' return value

' Put the date information into the structure.
systime.wYear = 1999
systime.wMonth = 10
systime.wDay = 3
systime.wHour = 16
systime.wMinute = 46
systime.wSecond = 0
systime.wMillisecond = 0

' Set the system clock to that time and date.
retval = SetSystemTime(systime)

See Also

GetSystemTime

Category

Time

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: October 3, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/setsystemtime.html