设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1749|回复: 4
打印 上一主题 下一主题

[模块/函数] 在前台工作站上如何得到后台服务器的日期??

[复制链接]
跳转到指定楼层
1#
发表于 2010-3-2 09:17:03 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
在access中,在前台工作站上如何得到后台服务器的日期??
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
4#
发表于 2010-3-10 15:46:29 | 只看该作者
  thanks
3#
发表于 2010-3-3 13:21:49 | 只看该作者
Private Declare Function NetRemoteTOD Lib "Netapi32.dll" ( _
    tServer As Any, pBuffer As Long) 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

'

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

'

Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

'

Private Declare Function NetApiBufferFree Lib "Netapi32.dll" (ByVal lpBuffer As Long) As Long

'

Private Type TIME_OF_DAY_INFO

    tod_elapsedt As Long

    tod_msecs As Long

    tod_hours As Long

    tod_mins As Long

    tod_secs As Long

    tod_hunds As Long

    tod_timezone As Long

    tod_tinterval As Long

    tod_day As Long

    tod_month As Long

    tod_year As Long

    tod_weekday As Long

End Type

'

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

'

'

Public Function getRemoteTOD(ByVal strServer As String) As Date

'

    Dim result As Date

    Dim lRet As Long

    Dim tod As TIME_OF_DAY_INFO

    Dim lpbuff As Long

    Dim tServer() As Byte

'

    tServer = strServer & vbNullChar

    lRet = NetRemoteTOD(tServer(0), lpbuff)

'

    If lRet = 0 Then

        CopyMemory tod, ByVal lpbuff, Len(tod)

        NetApiBufferFree lpbuff

        result = DateSerial(tod.tod_year, tod.tod_month, tod.tod_day) + _
        TimeSerial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs)

        getRemoteTOD = result

    Else

        err.Raise Number:=vbObjectError + 1001, _
        Description:="cannot get remote TOD"

    End If

'

End Function





'要运行该程序,通过如下方式调用。



Private Sub gettime()

    Dim d As Date

'

    d = getRemoteTOD("服务器名称")

    MsgBox d

End Sub
2#
发表于 2010-3-2 13:25:16 | 只看该作者
net time
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-21 05:40 , Processed in 0.082509 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表