修改本机与服务器时间一致的函数-AngelHis
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


修改本机与服务器时间一致的函数

发表时间:2016/3/25 22:15:20 评论(0) 浏览(5319)  评论 | 加入收藏 | 复制
   
摘 要:移植于vb的代码,修改本地系统时间,与服务器时间一致。
正 文:

入参 impTime 为之前获取的服务器时间,可以参考:http://www.accessoft.com/blog/article-show.asp?userid=20576&Id=9810

 

Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long

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


Function SetTime(impTime As Date) As Long  
    '    设置时间数据
    Dim lpSystemTime As SYSTEMTIME
    With lpSystemTime
        .wYear = Year(impTime)
        .wMonth = Month(impTime)
        .wDay = Day(impTime)
        .wHour = Hour(impTime) - 8  '
        .wMinute = Minute(impTime)
        .wSecond = Second(impTime)
        .wMilliseconds = 0
    End With
'    MsgBox Year(impTime) & Month(impTime) & Day(impTime) & Hour(impTime) & Minute(impTime) & Second(impTime)
    SetTime = SetSystemTime(lpSystemTime)
    If SetTime = 0 Then
        MsgBox "修改系统时间失败!", vbCritical + vbOKOnly, "失败"
    End If
End Function

Access软件网交流QQ群(群号:198465573)
 
 相关文章
在MDB中获取sqlserver服务器时间  【竹笛  2010/1/11】
取服务器时间  【男儿当自强  2010/8/2】
access开发平台企业版读取服务器时间  【一杯绿茶  2010/11/24】
【access源码示例】获取局域网中指定电脑上的时间\获取服务器时...  【红尘如烟  2012/3/1】
快速开发平台(企业版)--获取SQL SERVER服务器时间  【smileyoufu  2013/11/29】
获取Oracle服务器时间(ADO)  【在水一方  2014/12/5】
常见问答
技术分类
相关资源
文章搜索
关于作者

AngelHis

文章分类

文章存档

友情链接