Getting NT server system time... 
Author Message
 Getting NT server system time...

Hello,

I have searched everywhere for a way to get the current time off of a NT
server.  I can do it with Novell...Can anyone please give me a hand here?

Thank you!
Eric Schuele



Mon, 25 Jun 2001 03:00:00 GMT  
 Getting NT server system time...

This will do it for you.

John Timney (MVP)

Quote:
>I have searched everywhere for a way to get the current time off of a NT
>server.  I can do it with Novell...Can anyone please give me a hand here?

Option Explicit

Private Declare Function NetRemoteTOD Lib "NETAPI32.DLL" (ByVal server As
String, buffer As Any) As Long
Private Declare Function NetApiBufferFree Lib "NETAPI32.DLL" (ByVal buffer
As Long) As Long
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest
As Any, hpvSource As Any, ByVal cbCopy As Long)

Private Type TIME_OF_DAY
    t_elapsedt As Long
    t_msecs As Long
    t_hours As Long
    t_mins As Long
    t_secs As Long
    t_hunds As Long
    t_timezone As Long
    t_tinterval As Long
    t_day As Long
    t_month As Long
    t_year As Long
    t_weekday As Long
End Type
Private Sub Command1_Click()
    Dim t As TIME_OF_DAY, tPtr As Long, res As Long, szServer As String,
days As Date, todays As Date
    szServer = StrConv("\\ntsig", vbUnicode)    'Convert the server name to
unicode
    res = NetRemoteTOD(szServer, tPtr)  'You could also pass vbNullString
for the server name
    If res = 0 Then
        CopyMemory t, ByVal tPtr, Len(t) 'Copy the pointer returned to a
TIME_OF_DAY structure
        days = DateSerial(70, 1, 1) + (t.t_elapsedt / 60 / 60 / 24)
'Convert the elapsed time since 1/1/70 to a date
        days = days - (t.t_timezone / 60 / 24)  'Adjust for TimeZone
differences
            'Get local computer information for comparison
        todays = DateSerial(70, 1, 1) + (DateDiff("s", DateSerial(70, 1, 1),
Now()) / 60 / 60 / 24)
        Me.Cls
        Print DateDiff("s", DateSerial(70, 1, 1), Now()), todays,
t.t_elapsedt, days
        NetApiBufferFree (tPtr) 'Free the memory at the pointer
    Else
        MsgBox "Error occurred call NetRemoteTOD: " & res, vbOKOnly,
"NetRemoteTOD"
        'Error 53: cannot find server
    End If
End Sub



Tue, 26 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting the NT Server Time

2. Getting the NT Server Time

3. Getting the NT Server Time

4. Getting the NT Server Time

5. Set System Time to Server Time

6. Set local system time to file server time

7. Getting List of Installed Software REMOTELY from NT systems without using WMI

8. getting time zone from system

9. Getting System Time?

10. Getting System Time Over a Network..

11. Getting the system time in hundreds of seconds

12. Getting the System Time

 

 
Powered by phpBB® Forum Software