|
-
Sep 12th, 2000, 04:00 PM
#1
Thread Starter
Member
Is there way to get Time Zone information and possibly change it using Windows API?
-
Sep 12th, 2000, 10:31 PM
#2
Sure!
Code:
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To 31) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(0 To 31) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Declare Function SetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Public Function GetTimeZone() As String
Dim tZone As TIME_ZONE_INFORMATION
Dim lngRet As Long
Dim i As Long
Dim strBuffer As String
lngRet = GetTimeZoneInformation(tZone)
For i = 0 To 31 ' the array's range is from 0 to 31
If tZone.StandardName(i) = 0 Then Exit For
strBuffer = strBuffer & Chr(tZone.StandardName(i)) 'convert the ASCII code into a character
Next
GetTimeZone = strBuffer
End Function
Private Sub Command1_Click()
MsgBox GetTimeZone
End Sub
To Set TimeZone information, you have to run SetTimeZoneInformation, passing the TIME_ZONE_INFORMATION structure with time zone you want. If you pass ivalid time zone name, the function will fail.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|