如何取得局域网内的一台主机的时间

sstg9 2005-02-24 11:54:09
如何取得局域网内的一台主机的时间,请给出原码?谢谢!
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxcc 2005-02-24
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3659/3659671.xml?temp=.0499689

http://community.csdn.net/Expert/topic/3622/3622187.xml?temp=.5256159
zyg0 2005-02-24
  • 打赏
  • 举报
回复
饮用Inet1控件
zyg0 2005-02-24
  • 打赏
  • 举报
回复
如果这台机器有iis就能这样解决
Option Explicit

Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) 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 Sub Form_Load()
Dim lpSystemTime As SYSTEMTIME
Dim currentTime As Date
Dim xDate As String

Inet1.Execute "ip地址", "post"
Do While Inet1.StillExecuting
DoEvents
Loop

xDate = Mid(Inet1.GetHeader("Date"), InStr(1, Inet1.GetHeader("Date"), ",", vbTextCompare) + 1)

xDate = Trim(Left(xDate, InStr(1, xDate, "GMT", vbTextCompare) - 1))
currentTime = CDate(xDate)

With lpSystemTime
.wYear = DatePart("yyyy", currentTime)
.wMonth = DatePart("m", currentTime)
.wDay = DatePart("d", currentTime)
.wHour = DatePart("h", currentTime)
.wMinute = DatePart("n", currentTime)
.wSecond = DatePart("s", currentTime)
.wMilliseconds = 0
End With
Call SetSystemTime(lpSystemTime)

Me.Print "GMT:" & currentTime
Me.Print "SYS:" & Date & " " & Time
End Sub

viena 2005-02-24
  • 打赏
  • 举报
回复
shell "net time \\主机Name>c:\\time.txt",vbhide

然后分析time.txt

1,502

社区成员

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

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