我现在需要获取一个网络计算机的系统时间的解决办法,例如局域网内任何一台计算机的系统时间。急需!谢谢!!

解决方案 »

  1.   

    如果你是在Windows NT上运行程序,可以使用Windows API的NetRemoteTOD函数获得服务器的时间。不过这个函数不为Windows 95支持。所以在Windows 95下,简单的办法是用Shell调用NET TIME //<servername> 命令获得时间,你可以将输出重定向到一个文件,然后在VB读取这个文件以获得时间。
      

  2.   

    支持 Surpass(网络飞狐) 
    确实只有这个办法最简单了
      

  3.   

    我是在Win98上运行程序,大家在帮我好好想想,是不是有其它更好的办法了!谢谢各位了!
      

  4.   

    Option Explicit
    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 TypePrivate 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 TypePrivate Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As LongPrivate 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 Command1_Click()
        Dim d As Date
        d = getRemoteTOD("\\trade")
        MsgBox d
    End Sub