怎样编程获取另一微机的时钟(非net time方法)?

思考 2003-03-31 08:25:38
在win98下怎样编程获取另一微机的时钟,不用 net time方法
有api函数吗?
...全文
47 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
BAYERN 2003-04-03
  • 打赏
  • 举报
回复
等着看。。。。。。。。。。。。。
思考 2003-04-03
  • 打赏
  • 举报
回复
再up
lxcc 2003-04-02
  • 打赏
  • 举报
回复
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 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 Command1_Click()

  Dim d as date

'

  d = GetRemoteTOD("your NT server name goes here")

  MsgBox d

End Sub

lxcc 2003-04-02
  • 打赏
  • 举报
回复
up
思考 2003-04-02
  • 打赏
  • 举报
回复
up
flowerboyhgc 2003-04-02
  • 打赏
  • 举报
回复
up
思考 2003-04-02
  • 打赏
  • 举报
回复
谢谢,楼上的是指win2000吧,那在win98下呢?
思考 2003-04-02
  • 打赏
  • 举报
回复
没有sql-server,只想取对方计算机时钟,不想校对本机时钟
cbr7619 2003-04-02
  • 打赏
  • 举报
回复
如果对方机上有sql-server的话,
可用getdate()函数使得两机的时间一致
思考 2003-04-02
  • 打赏
  • 举报
回复
谢谢,可是在win98下不行啊,找不到 DLL 入口点 NetRemoteTOD in Netapi32.dll
NowCan 2003-04-02
  • 打赏
  • 举报
回复
98???
_131_ 2003-03-31
  • 打赏
  • 举报
回复
打电话去问问,然后写到程序里面!
思考 2003-03-31
  • 打赏
  • 举报
回复
up
watt 2003-03-31
  • 打赏
  • 举报
回复
i don't know.
lxcc 2003-03-31
  • 打赏
  • 举报
回复
up
思考 2003-03-31
  • 打赏
  • 举报
回复
要求对方的计算机不能安装任何软件,如winsock
NowCan 2003-03-31
  • 打赏
  • 举报
回复

'NETAPI32
Private Declare Function NetRemoteTOD Lib "NETAPI32.DLL" (ByVal UncServerName As String, ByVal BufferPtr As String) As Long

思考 2003-03-31
  • 打赏
  • 举报
回复
看来还得用 Net Time \\计算机名 >a.txt
5555555555555555555 !!!

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧