GetTimeZoneInformation Function

Declare Function GetTimeZoneInformation Lib "kernel32.dll" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Platforms: Win 95/98, Win NT

GetTimeZoneInformation reads the computer's current time zone settings. Since Windows handles all of the system clock settings, there usually isn't a need for other programs to use this information. The information is put into the variable passed as lpTimeZoneInformation. The function returns 0 if an error occured, or a 1 if successful.

lpTimeZoneInformation
Variable which receives the information about the system time zone.

Example:

' Display the name of the time zone the computer is set to.
Dim tzi As TIME_ZONE_INFORMATION  ' receives information on the time zone
Dim retval As Long  ' return value
Dim c As Long  ' counter variable needed to display time zone name

retval = GetTimeZoneInformation(tzi)  ' read information on the computer's selected time zone

' Oddly, instead of being stored in a string, the time zone name is stored in a
' 32-element array, each element holding the ASCII code of one of the characters.
' This loop converts the array into a readable string.
Debug.Print "The computer's time zone is: ";
For c = 0 To 31  ' the array's range is from 0 to 31
  If tzi.StandardName(c) = 0 Then Exit For  ' abort if the terminating null character is reached
  Debug.Print Chr(tzi.StandardName(c))  ' convert the ASCII code into a character and display it
Next c
Debug.Print ""  ' end the line being displayed

Category: Time

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


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
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/g/gettimezoneinformation.html