home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 4.00 Begin VB.Form frmTime Caption = "Time Demonstration" ClientHeight = 3525 ClientLeft = 1140 ClientTop = 1515 ClientWidth = 4530 Height = 3930 Left = 1080 LinkTopic = "Form1" ScaleHeight = 3525 ScaleWidth = 4530 Top = 1170 Width = 4650 Begin VB.Frame Frame1 Caption = "Time Zone Info" Height = 2055 Left = 60 TabIndex = 6 Top = 1140 Width = 4095 Begin VB.TextBox txtTZSName Height = 285 Left = 1260 TabIndex = 12 Top = 960 Width = 2115 End Begin VB.TextBox txtTZBias Height = 285 Left = 1260 TabIndex = 8 Top = 360 Width = 1515 End Begin VB.TextBox txtTZName Height = 285 Left = 1260 TabIndex = 7 Top = 660 Width = 2115 End Begin VB.Label Label5 Caption = "Savings Name:" Height = 195 Left = 120 TabIndex = 11 Top = 1020 Width = 1575 End Begin VB.Label Label6 Caption = "Time Diff." Height = 195 Left = 120 TabIndex = 10 Top = 420 Width = 675 End Begin VB.Label Label7 Caption = "Zone Name:" Height = 195 Left = 120 TabIndex = 9 Top = 720 Width = 975 End End Begin VB.TextBox txtAdjust Height = 285 Left = 1260 TabIndex = 5 Top = 660 Width = 1515 End Begin VB.TextBox txtSysTime Height = 285 Left = 1260 TabIndex = 3 Top = 360 Width = 1515 End Begin VB.TextBox txtLocTime Height = 285 Left = 1260 TabIndex = 1 Top = 60 Width = 1515 End Begin VB.Timer Timer1 Interval = 1000 Left = 3540 Top = 480 End Begin VB.Label Label3 Caption = "Adjustment:" Height = 195 Left = 60 TabIndex = 4 Top = 720 Width = 975 End Begin VB.Label Label2 Caption = "System Time:" Height = 195 Left = 60 TabIndex = 2 Top = 420 Width = 975 End Begin VB.Label Label1 Caption = "Local Time:" Height = 195 Left = 60 TabIndex = 0 Top = 120 Width = 1095 End Attribute VB_Name = "frmTime" Attribute VB_Creatable = False Attribute VB_Exposed = False Option Explicit Private Const LOCALE_SYSTEM_DEFAULT& = &H800 Private Const LOCALE_USER_DEFAULT& = &H400 '********************************** '** Type Definitions: #If Win32 Then Private Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Private Type TIME_ZONE_INFORMATION Bias As Long StandardName As String * 64 StandardDate As SYSTEMTIME StandardBias As Long DaylightName As String * 64 DaylightDate As SYSTEMTIME DaylightBias As Long End Type #End If 'WIN32 Types '********************************** '** Function Declarations: #If Win32 Then Private Declare Function GetLocaleInfo& Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Sub GetSystemTimeAdjustment Lib "kernel32" (lpTimeAdjustment As Long, lpTimeIncrement As Long, lpTimeAdjustmentDisabled As Long) Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) Private Declare Function GetTimeZoneInformation& Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) Private Declare Function GetTimeFormat& Lib "kernel32" Alias "GetTimeFormatA" _ (ByVal Locale As Long, ByVal dwFlags As Long, lpTime As SYSTEMTIME, _ ByVal lpFormat As Long, ByVal lpTimeStr As String, ByVal cchTime As Long) #End If 'WIN32 Private Sub Form_Load() Dim myTZ As TIME_ZONE_INFORMATION Dim myAdj&, myIncr&, myDisabled& Dim s$, dl& GetSystemTimeAdjustment myAdj&, myIncr&, myDisabled& If myDisabled& Then txtAdjust = "Disabled." Else txtAdjust = myAdj& & " ns Every " & myIncr& & " ns." End If dl& = GetTimeZoneInformation(myTZ) txtTZBias = CInt(myTZ.Bias / 30) / 2 & " hours" s$ = myTZ.StandardName txtTZName = StrConv(s$, vbFromUnicode) s$ = myTZ.DaylightName txtTZSName = StrConv(s$, vbFromUnicode) End Sub ' Obtain the system and local time and display them Private Sub Timer1_Timer() Dim myTime As SYSTEMTIME, s$, dl& GetLocalTime myTime s$ = String$(255, Chr$(0)) dl& = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, 0, s$, 254) txtLocTime = s$ GetSystemTime myTime s$ = String$(255, Chr$(0)) dl& = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, 0, s$, 254) txtSysTime = s$ End Sub Private Sub txtNum_Change() End Sub Private Sub txtLocTime_Change() End Sub