API 设置调整系统当前时间
时间:2009-06-13 08:51 来源:本站原创 作者:andymark 阅读:次
对于时间要求比较严谨的情况下,需要对当前系统时间和外部时间作一个对比,并作相应的调整,这就要求能对系统时间重新设置
CODE:
'**************************************************
'
' 功能: 重新设置系统时间
' 用法: SetTime "2008-4-26 22:53:48"
' 作者: andymark
' QQ : 42503577 ; Email: ewang11@163.com
' 备注:
'
'**************************************************
'设置当前系统时间
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
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(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Public Sub SetTime(NewTime As String)
' 功能: 设置系统时间
Dim lpSystemTime As SYSTEMTIME '时间信息
Dim ZoneNum As Integer
ZoneNum = getZoneNum()
With lpSystemTime
.wYear = Year(NewTime)
.wMonth = Month(NewTime) + 1
.wDayOfWeek = -1
.wDay = Day(NewTime)
.wHour = Hour(NewTime) + ZoneNum
.wMinute = Minute(NewTime)
.wSecond = Second(NewTime)
.wMilliseconds = 0
End With
SetSystemTime lpSystemTime
End Sub
Private Function getZoneNum() As Integer
Dim lpSystemZone As TIME_ZONE_INFORMATION '时区信息
GetTimeZoneInformation lpSystemZone
getZoneNum = lpSystemZone.Bias / 60
End Function
(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
相关内容
- ·API函数详细解释
- ·Access从剪切版里复制和粘贴数据
- ·Access利用api实现打开/关闭光驱
- ·应用程序开机自动启动(注册表操作技巧
- ·Access VBA 判断网络是否连通的多种办
- ·什么是ADP,了解ADP的优缺点
- ·优秀产品大全--通用票据打印软件(新)
- ·[技巧分享]多条Shell语句执行导致判断
- ·在access中可以调用API函数GetFileInfo
- ·Access API集中营--增加临时使用的字体
- ·API ShellExecute 功能说明及应用示例
- ·在VB中使用API函数(什么是API? )
- ·API实现完美的图片出现效果(转)
- ·API 设置调整系统当前时间
- ·如何检测以及设置键盘状态
- ·不关闭当前数据库COPY当前数据库
最新内容
推荐内容