[RESOLVED] Can't add a reference to the specified file
I am having a problem trying to reference the CEUtil.dll file in my VB6 application. When I try to reference the DLL, I get the following error message: "Can't add a reference to the specified file." I, then, went to verify that it was registered so I used regsvr32 to register ceutil.dll, and I recieved the following error message: "CEUtil.dll was loaded, but the DLLRegisterServer entry point was not found. The file cannot be registered." I am new to working with DLL files in VB6, so any help would be great. Thanks again!
Re: Can't add a reference to the specified file
Is this a COM DLL?
:wave:
Re: Can't add a reference to the specified file
It sounds as if it is a standard DLL (like C++ produces), rather than an ActiveX DLL (like VB produces).
That means you cannot add a Reference, but instead need to declare each of the functions you want to use, which would be something like this:
Code:
Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
However, without the developer documentation for the DLL, you won't know what the functions are called, or what parameters they need.
Re: Can't add a reference to the specified file
Thanks Si, you rock (as usual). Teh function I want to declare is called getDeviceID(void); now I've never used DLLs in a VB program like this. Once I add the following line; I there anything else in my code I will need to do?
Private Declare Sub getDeviceID() Lib "CEUtil.dll"()
Thanks!
Re: Can't add a reference to the specified file
If getDeviceID doesn't take any parameters and doesn't return anything, that is correct - and to call it you can use either of these:
Code:
getDeviceID
Call getDeviceID
However.. I would expect something with that name to return a value. Perhaps it should be like this (depending on what data type is returned):
Code:
Private Declare Function getDeviceID() Lib "CEUtil.dll"() as Long
..and could be called like either of these:
Code:
MsgBox getDeviceID
MyVariable = getDeviceID
Re: Can't add a reference to the specified file
I'm now getting "Error 453 - Can't find DLL entry point GetDeviceID in C:\WINNT\System32\ceutil.dll". Could it be that the GetDeviceID function does not exist in the ceutil.dll file? Is there a way I can view the contents of the ceutil.dll file, which seems to be a fairly standard Microsoft file. Thanks!
Re: Can't add a reference to the specified file
It could be that the function does not exist, but it is more likely that the parameters or return type are not correct.
See if you also have a file called ceutil.h, as that is a text file which contains the declarations.
edit:
based on this documentation it seems that the name is wrong - it should be ceGetDeviceID
It also returns a value, but it is hard to tell what data type it should be, as the one listed is "DEVICEID" (which is not a normal data type). Based on experience I would guess that it is a Long, in which case the code would be like this:
Code:
Private Declare Function ceGetDeviceID() Lib "CEUtil.dll"() as Long
Re: Can't add a reference to the specified file
Thanks to all those who commented, but I was successfully able to do this with the following code:
Code:
Private Declare Function CeGetDeviceId Lib "C:\WINNT\system32\ceutil.dll" () As Boolean
If CeGetDeviceId() = False Then
Dim num As Integer
num = MsgBox("Handheld scanner not detected. Exiting ScanTransferV3 application.", vbCritical, "CeGetDeviceId() Failed")
End
End If
Thanks Again !!