GetTimeZone

Get local timezone
Uses w32tm / tz dos command in command prompt
Using temporary file that can be changed

Function GetTimeZone( Optional File2 = "C:\File1.txt" )
 ' w32tm /tz >D:\my\projects\someproj\file1.txt
 ' File2 = "C:\File1.txt"
 Shell "cmd /c w32tm /tz > " & File2
 DoEvents
 Application.Wait (Now + TimeValue("0:00:1"))
 DoEvents
 ' wait for it to finish, then ...
 Dim iFile As Integer
 iFile = FreeFile()
 Open File2 For Input As #iFile
 Dim sData As String
 sData = Input(LOF(iFile), #iFile)
 Close #iFile
 DoEvents
 Kill File2
 Rett="N/A"
 AN2 = "Standard Name:"
 AN1 = InStr(1, sData, AN2, vbTextCompare)
 AN3 = InStr(AN1, sData, " Bias") - AN1 - Len(AN2)
 If AN1 > 0 Then Rett = Mid(sData, AN1 + Len(AN2) + 1, AN3 - 2)
 GetTimeZone = Rett
End Function

Parameters

Optional File2

Views 125 Downloads 51

Perm link