如何取得局域网内的一台主机的时间,请给出原码?谢谢!

解决方案 »

  1.   

    shell "net time \\主机Name>c:\\time.txt",vbhide然后分析time.txt
      

  2.   

    如果这台机器有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
      

  3.   

    http://community.csdn.net/Expert/topic/3659/3659671.xml?temp=.0499689http://community.csdn.net/Expert/topic/3622/3622187.xml?temp=.5256159