各位专家:
    向大家请教上面的问题!
    我的联系方式:QQ -> 89402804  E-MAIL -> [email protected]
    欢迎各位与我联系 ^_^

解决方案 »

  1.   

    补充说明:
    我用工作站的VB编程序做的每个操作,希望不读取本机日期时间,想读取服务器时间!
    听说VB中有个函数能实现,不知道哪位专家了解?
      

  2.   

    人家是编程用,你这个是CMD.在VB中怎么用?
      

  3.   

    TO bingxuehuiren(冰雪慧儿):这样用~~'保证连网计算机时间同步☆
    '
    '执行命令:
    'net time "\\OhterComputerName" /set /yes 可以保证名称为OhterComputerName 的计算机与本机时间同步。
    'Public Sub SyncTime()
    'Dim thecomp As String
    'Dim theshell As String
    'thecomp = "\\computername"
    'theshell = "net time " & Chr(34) & thecomp & Chr(34) & " /set /yes"
    'x = Shell(theshell)
    'End Sub
    Private Function SyncTime(ByVal ServerName As String) As BooleanDim theshell As String
    On Error GoTo Error_SyncTime
        theshell = "net time " & Chr(34) & "\\" & ServerName & Chr(34) & " /set /yes"
        x = Shell(theshell)
        SyncTime = True
    Exit FunctionError_SyncTime:
        SyncTime = FalseEnd FunctionPrivate Sub cmdSet_Click()    If SyncTime(Trim(txtSetTime.Text)) Then MsgBox "同步时间成功!"End Sub
      

  4.   

    VB+MSSQLPublic Function Gettime() As Date  '取服务器时间
        Dim rs As New ADODB.Recordset
        on error goto err
        Set rs = "select getdate() as dd", CN, adOpenKeyset, adLockOptimistic, adCmdText
        If rs.RecordCount > 0 Then Gettime = rs.Fields(0).Value
        err:
    If Not rs Is Nothing Then
        If rs.State <> adStateClosed Then
            rs.Close
            Set rs = Nothing
        Else
            Set rs = Nothing
        End If
    End If
    End Function
      

  5.   

    to w18ily(真的被封了,这次翘翘了) 
    那可是我要用MSGBOX显示服务器的时间如何做?那个变量C反回的是ID号呀.
    不想连SQL呢?连SQL的李大虾已经指点过了,好使.
      

  6.   

    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 TypePrivate 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 TypePrivate Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As LongPrivate 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("\\机器名称")
        MsgBox d
    End Sub
      

  7.   

    多谢各位,lxcc(虫莲) 的见解还是很实用的 :)
      

  8.   

    lxcc(虫莲) You are very good!
    You are real daxia!!!!!!
      

  9.   

    lxcc(虫莲):   We love you!
      

  10.   

    To:lxcc(虫莲) 你的这个程序是不是只能在2000以上的版本运行阿?我在98下执行包错"NetRemoteTOD在Netapi32.dll中找不到入口点"......:'(