please help.
I want to be able to change my computer's system "Time Zone" via vb.net
code. is it possible?
-mike
The short answer is "Probably".
I had an old example of this written in VB6 for use in Win98.
The basis of the example uses the API, SetTimeZoneInformation which,
in Net, would be:
Public Declare Function SetTimeZoneInformation _
Lib "kernel32" (ByRef lpTimeZoneInformation _
As TIME_ZONE_INFORMATION) As Integer
However, the old TYPE definition for TIME_ZONE_INFORMATION would not
be valid for NT systems and NET.
Public Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(31) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(31) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
You would need to update this to a valid working Structure. I found 3
different versions using a quick "google", with this one looking the
most ominous:
Public Structure TIME_ZONE_INFORMATION
Dim Bias As Integer
<VBFixedString(64), System.Runtime.InteropServices. _
MarshalAs(System.Runtime.InteropServices. _
UnmanagedType.ByValTStr, SizeConst:=64)> _
Public StandardName As String
Dim StandardDate As SYSTEMTIME
Dim StandardBias As Integer
<VBFixedString(64), System.Runtime.InteropServices. _
MarshalAs(System.Runtime.InteropServices. _
UnmanagedType.ByValTStr, SizeConst:=64)> _
Public DaylightName As String
Dim DaylightDate As SYSTEMTIME
Dim DaylightBias As Integer
End Structure
TimeZone definitions for a given system are found in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones
Theoretically, you should be able to set the system time zone to any
one of those named Time Zones.
Long answer: Yes, but would depend on you NET skill level.
Gene