GetTimeZone

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

CodeFunctionName
What is this?

Public

Tested

Original Work
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

Optional File2

Views 4,703

Downloads 1,401

CodeID
DB ID