GetTimeZoneInformation VB声明 
Declare Function GetTimeZoneInformation Lib "kernel32" Alias "GetTimeZoneInformation" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long 
说明 
在一个TIME_ZONE_INFORMATION结构中载入与系统时区设置有关的信息 
返回值 
Long,下述常数之一: 
TIME_ZONE_ID_INVALID 函数执行失败,会设置GetLastError 
TIME_ZONE_ID_UNKNOWN 时区未知(可能仍然指定了bias值) 
TIME_ZONE_ID_STANDARD 标准时间有效 
TIME_ZONE_ID_DAYLIGHT 夏令时有效 
参数表 
参数 类型及说明 
lpTimeZoneInformation TIME_ZONE_INFORMATION,用于载入时区信息的结构 
注解 
在lpTimeZoneInformation结构中为本地时间添加bias信息,从而获得系统时间。TIME_ZONE_INFORMATION结构内部的DaylightName和StandardName字串肯定采用Unicode格式

解决方案 »

  1.   

    TIME_ZONE_INFORMATION 类型定义 
    Type TIME_ZONE_INFORMATION ' 172 Bytes
    Bias As Long
    StandardName(32) As Integer
    StandardDate As SYSTEMTIME
    StandardBias As Long
    DaylightName(32) As Integer
    DaylightDate As SYSTEMTIME
    DaylightBias As Long
    End Type 
    说明 
    This structure contains information about the time zone for this system.
     
    字段表 
    字段 类型与说明 
    Bias Long,Used to translate local time into coordinated universal time (UTC) time. The bias is the difference, in minutes, between UTC and local time. The following formula is used: UTC = local time + bias. 
    StandardName Integer Array,A double-byte null-terminated Unicode string that describes the standard time zone for the system. This field is not used internally and may be set to zero. 
    StandardDate SYSTEMTIME,Contains a date and UTC time describing when the transition from daylight time to standard time occurs on this system. Set the wMonth field to zero to ignore this field. 
    StandardBias Long,Value to add to the Bias field when standard time is in effect. Ignored if StandardDate is not used. 
    DaylightName Integer Array,A double-byte null-terminated Unicode string used to describe the daylight time zone for this system. This field is not used internally and may be set to zero. 
    DaylightDate SYSTEMTIME,Contains a date and UTC time describing when the transition from standard time to daylight time occurs on this system. Set the wMonth field to zero to ignore this field. 
    DaylightBias Long,Value to add to the Bias field when daylight saving time is in effect. Ignored if DaylightDate is not used. 
      

  2.   

    SYSTEMTIME 类型定义 
    Type SYSTEMTIME ' 16 Bytes 
    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 
    说明 
    This structure contains date and time information.
     
    字段表 
    字段 类型与说明 
    wYear Integer,The current year. 
    wMonth Integer,The current month. January is 1. 
    wDayOfWeek Integer,The current day of the week. Sunday is 0. 
    wDay Integer,The current day of the month. 
    wHour Integer,The current hour. 
    wMinute Integer,The current minute. 
    wSecond Integer,The current second. 
    wMilliseconds Integer,The current millisecond.