L
Linda Liu [MSFT]
Hi Steve,
You can make use of the Win32 API function GetTimeZoneInformation in your
application to get the current time zone on the local machine.
The following is a sample.
Imports System.Runtime.InteropServices
Public Class Form1
<StructLayout(LayoutKind.Sequential)> _
Public Structure SYSTEMTIME
Public wYear As UInt16
Public wMonth As UInt16
Public wDayOfWeek As UInt16
Public wDay As UInt16
Public wHour As UInt16
Public wMinute As UInt16
Public wSecond As UInt16
Public wMilliseconds As UInt16
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure TIME_ZONE_INFORMATION
<MarshalAs(UnmanagedType.I4)> _
Public Bias As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public StandardName As String
Public StandardDate As SYSTEMTIME
<MarshalAs(UnmanagedType.I4)> _
Public StandardBias As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public DaylightName As String
Public DaylightDate As SYSTEMTIME
<MarshalAs(UnmanagedType.I4)> _
Public DaylightBias As Int32
End Structure
Declare Auto Function GetTimeZoneInformation Lib "kernel32.dll" (ByRef
lpTimeZoneInformation As TIME_ZONE_INFORMATION) As UInt32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim tziNative As TIME_ZONE_INFORMATION
GetTimeZoneInformation(tziNative)
End Sub
End Class
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
You can make use of the Win32 API function GetTimeZoneInformation in your
application to get the current time zone on the local machine.
The following is a sample.
Imports System.Runtime.InteropServices
Public Class Form1
<StructLayout(LayoutKind.Sequential)> _
Public Structure SYSTEMTIME
Public wYear As UInt16
Public wMonth As UInt16
Public wDayOfWeek As UInt16
Public wDay As UInt16
Public wHour As UInt16
Public wMinute As UInt16
Public wSecond As UInt16
Public wMilliseconds As UInt16
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure TIME_ZONE_INFORMATION
<MarshalAs(UnmanagedType.I4)> _
Public Bias As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public StandardName As String
Public StandardDate As SYSTEMTIME
<MarshalAs(UnmanagedType.I4)> _
Public StandardBias As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public DaylightName As String
Public DaylightDate As SYSTEMTIME
<MarshalAs(UnmanagedType.I4)> _
Public DaylightBias As Int32
End Structure
Declare Auto Function GetTimeZoneInformation Lib "kernel32.dll" (ByRef
lpTimeZoneInformation As TIME_ZONE_INFORMATION) As UInt32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim tziNative As TIME_ZONE_INFORMATION
GetTimeZoneInformation(tziNative)
End Sub
End Class
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.