找回密码
 加入
搜索
查看: 5066|回复: 4

[系统综合] 如何获取局域网某台电脑的系统时间?(VB代码转AU3)

[复制链接]
发表于 2014-10-14 13:53:16 | 显示全部楼层 |阅读模式
从网上搜索到使用NettRemoteTOD API可以做到,下面是VB代码,哪位大神可以帮忙改为AU3代码。 多谢!!
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 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 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 Form_Load()
    Dim d As Date
    d = getRemoteTOD("192.168.186.110")
    MsgBox d
End Sub
 楼主| 发表于 2014-10-16 08:51:12 | 显示全部楼层
顶一下,大神帮帮忙!!
发表于 2014-10-16 09:12:47 | 显示全部楼层
发表于 2014-10-24 09:52:36 | 显示全部楼层
楼主看下3楼代码,是个很好的例子,跟着学习下~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-2 09:13 , Processed in 0.073806 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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