467,122 Members | 1,243 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,122 developers. It's quick & easy.

How to change computer's "Time Zone" from vb.net

please help.
I want to be able to change my computer's system "Time Zone" via vb.net
code. is it possible?

-mike
May 30 '06 #1
  • viewed: 7491
Share:
1 Reply
On Tue, 30 May 2006 16:38:04 +0800, "Michael Barrido"
<jm***@hotmail.com> wrote:
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
May 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by David Garamond | last post: by
1 post views Thread by princessjewel62@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.