Declare Function NetRemoteTOD Lib "Netapi32.dll" ( _ tServer As Any, pBuffer As Long) As Long
NetRemoteTOD возвращает дату и время удаленного компьютера.
В успешном случае функция возвращает NERR_Success. В случае ошибки функция возвращает коды ошибок.
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" ( _ ByVal lpBuffer As Long) As Long 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("\\skynet") MsgBox d End Sub