borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (how to create a screensaver in visual basic)Next Topic (Accessing Keys in Registry using API) New Topic New Poll Post Reply
AndreaVB Forum : API : can't find dll entry
Poster Message
chwong
Level: Guest


icon can't find dll entry

I copy the netapi32.dll - get time and date of a network machine server or workstation from the web page into Access see how it working. I get an error message as below:-

"can't find dll entry print NetRemoteTOD in netapi32.dll". The source code as below:-
This code i put it into modules.
Option Explicit

'API Structures
Type TIME_OF_DAY_INFO
    tod_elapsed 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

'NetAPI Calls
Public Declare Function NetRemoteTOD Lib "netapi32.dll" (yServer As Any, pBuffer As Long) As Long
Private Declare Function NetApiBufferFree Lib "netapi32.dll" (ByVal pBuffer As Long) As Long
'Kernel API Calls
Private Declare Sub CopyMem Lib "kernel32.dll" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)

'Return the Time and Date of a specified Machine on the Net
Public Function GetRemoteTime(ServerName As String) As Date
    Dim lpBuffer As Long
    Dim t_struct As TIME_OF_DAY_INFO
    Dim ret As Long
    Dim bServer() As Byte

    If Trim(ServerName) = "" Then
        'Local machine
        ret = NetRemoteTOD(vbNullString, lpBuffer)
    Else
        'Check the syntax of the ServerName string
        If InStr(ServerName, "\\") = 1 Then
            bServer = ServerName & vbNullChar
        Else
            bServer = "\\" & ServerName & vbNullChar
        End If
        ret = NetRemoteTOD(bServer(0), lpBuffer)
    End If
    CopyMem t_struct, ByVal lpBuffer, Len(t_struct)
    If lpBuffer Then
        Call NetApiBufferFree(lpBuffer)
    End If
    GetRemoteTime = DateSerial(t_struct.tod_year, t_struct.tod_month, t_struct.tod_day) + TimeSerial(t_struct.tod_hours, t_struct.tod_mins - t_struct.tod_timezone, t_struct.tod_secs)
End Function

This code i put in form
'Get the time and date of the local machine
Private Sub Command1_Click()
    MsgBox GetRemoteTime("")
End Sub

'Get the time and date a remote Workstation
Private Sub Command2_Click()
    MsgBox GetRemoteTime("\\MYWORKSTATION")
End Sub

When i click command 1 or command 2, it will show an error message "run time error "453" can't find dll entry print NetRemoteTOD in netapi32.dll

04-10-2003 at 03:19 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: can't find dll entry

NetRemoteTOD API is only supported on WinNT machines, not Win98, as I am aware. Try doing it with net time command on Win98


Shell "command.com /c net time \\" & strServerName & " >> date.txt", vbHide


And then open "date.txt" to read date and time on the server.

Hope this helped, Goran



____________________________
If you find the answer helpful, please mark this topic as solved.

04-10-2003 at 11:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
chwong
Level: Guest

icon Re: can't find dll entry

Thanks Goran! I have successfully did it. Any way, do you know any dll file can check the remote pc date and time for win98. Thanks a lot.

06-10-2003 at 05:43 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: can't find dll entry

Well, I dont know if there are any (probably are), but I think it wouldnt be hard to make one now that u have the code that works.



____________________________
If you find the answer helpful, please mark this topic as solved.

06-10-2003 at 12:09 PM
View Profile Send Email to User Show All Posts | Quote Reply
chwong
Level: Guest

icon Re: can't find dll entry

if i need to syschronize all the pc system date then how should i do?

07-10-2003 at 01:44 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: can't find dll entry


net time \\ServerName /set /y





____________________________
If you find the answer helpful, please mark this topic as solved.

07-10-2003 at 04:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
chwong
Level: Guest

icon Re: can't find dll entry

Thanks a lot. You'r great

08-10-2003 at 05:58 AM
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: can't find dll entry

You are welcome.  

____________________________
If you find the answer helpful, please mark this topic as solved.

09-10-2003 at 12:52 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : can't find dll entry
Previous Topic (how to create a screensaver in visual basic)Next Topic (Accessing Keys in Registry using API) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder