FoxAPI上面的 'Example Name:Determining a Locale's Standard and Daylight Time Zone Names'------------------------------------------------------------------------------ ' ' BAS Moduel Code ' '------------------------------------------------------------------------------ Option ExplicitPrivate Const TIME_ZONE_ID_UNKNOWN As Long = 1 Private Const TIME_ZONE_ID_STANDARD As Long = 1 Private Const TIME_ZONE_ID_DAYLIGHT As Long = 2 Private Const TIME_ZONE_ID_INVALID As Long = &HFFFFFFFFPrivate 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 TypePrivate Type TIME_ZONE_INFORMATION Bias As Long StandardName(0 To ((32 * 2) - 1)) As Byte 'unicode StandardDate As SYSTEMTIME StandardBias As Long DaylightName(0 To ((32 * 2) - 1)) As Byte 'unicode DaylightDate As SYSTEMTIME DaylightBias As Long End TypePrivate Declare Function GetTimeZoneInformation Lib "kernel32" _ (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As LongPrivate Sub Form_Load() Command1.Caption = "Get Time Zone Names"
End Sub Private Sub Command1_Click() Label1.Caption = Format$(Now, "long date") Text1.Text = GetStandardName() Text2.Text = GetDaylightName()End Sub Private Function GetDaylightName() As String Dim tzi As TIME_ZONE_INFORMATION Dim tmp As String Call GetTimeZoneInformation(tzi) tmp = tzi.DaylightName
GetDaylightName = TrimNull(tmp)End Function Private Function GetStandardName() As String Dim tzi As TIME_ZONE_INFORMATION Dim tmp As String Call GetTimeZoneInformation(tzi) tmp = tzi.StandardName
GetStandardName = TrimNull(tmp)
End Function Private Function TrimNull(item As String) Dim pos As Integer
'double check that there is a chr$(0) in the string pos = InStr(item, Chr$(0)) If pos Then TrimNull = Left$(item, pos - 1) Else: TrimNull = item End If
但是我没找到这个方法啊,
我是在vb6.0下面的,是不是要加入什么Reference啊?
'Example Name:Determining a Locale's Standard and Daylight Time Zone Names'------------------------------------------------------------------------------
'
' BAS Moduel Code
'
'------------------------------------------------------------------------------
Option ExplicitPrivate Const TIME_ZONE_ID_UNKNOWN As Long = 1
Private Const TIME_ZONE_ID_STANDARD As Long = 1
Private Const TIME_ZONE_ID_DAYLIGHT As Long = 2
Private Const TIME_ZONE_ID_INVALID As Long = &HFFFFFFFFPrivate 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 TypePrivate Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To ((32 * 2) - 1)) As Byte 'unicode
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(0 To ((32 * 2) - 1)) As Byte 'unicode
DaylightDate As SYSTEMTIME
DaylightBias As Long
End TypePrivate Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As LongPrivate Sub Form_Load() Command1.Caption = "Get Time Zone Names"
End Sub
Private Sub Command1_Click() Label1.Caption = Format$(Now, "long date")
Text1.Text = GetStandardName()
Text2.Text = GetDaylightName()End Sub
Private Function GetDaylightName() As String Dim tzi As TIME_ZONE_INFORMATION
Dim tmp As String Call GetTimeZoneInformation(tzi)
tmp = tzi.DaylightName
GetDaylightName = TrimNull(tmp)End Function
Private Function GetStandardName() As String Dim tzi As TIME_ZONE_INFORMATION
Dim tmp As String Call GetTimeZoneInformation(tzi)
tmp = tzi.StandardName
GetStandardName = TrimNull(tmp)
End Function
Private Function TrimNull(item As String) Dim pos As Integer
'double check that there is a chr$(0) in the string
pos = InStr(item, Chr$(0))
If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End Function