GregoryGr
asked on
Cant find DLL reference point
I used C++ V6 to compile and link a DLL that includes function calls. When I try to access functions from this DLL, I get the run-time error "Can't find DLL entry point ClfyConnect in notes2clarifydll".
I am thinking the problem is with the C++ DLL.
//////////////////////////
Sample calling code (VB6)...
Private Declare Function ClfyConnect Lib "notes2clarifydll" _
(ByVal sServer As String, ByVal sDatabase As String, _
ByVal sUsername As String, ByVal sPassword As String) As Long
////////////////////////// //////
Sample C++ code generating the DLL...
__declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);
I am thinking the problem is with the C++ DLL.
//////////////////////////
Sample calling code (VB6)...
Private Declare Function ClfyConnect Lib "notes2clarifydll" _
(ByVal sServer As String, ByVal sDatabase As String, _
ByVal sUsername As String, ByVal sPassword As String) As Long
//////////////////////////
Sample C++ code generating the DLL...
__declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One more thing. This may not be quite sufficient. There is one other type of name decoration and this doesn't dissable that. If after using extern "C" you find that the exported name (check with dumpbin) ends with a "@" followed by a number, they this is the standard call decoration.
To remove this decoration you need to place an entry in the DLL's module defintion file (.def). The entry should appear in the EXPORTS section and should just contain the name of the function. for example
// in your .cpp file
extern "C" __declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);
// in your .def file.
EXPORTS
ClfyConnect
let me know if you have any questions
To remove this decoration you need to place an entry in the DLL's module defintion file (.def). The entry should appear in the EXPORTS section and should just contain the name of the function. for example
// in your .cpp file
extern "C" __declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);
// in your .def file.
EXPORTS
ClfyConnect
let me know if you have any questions
The function is exported with the mangeled name, so you aren't actually specifying the right name in VB. You can use dumpbin to verify this, you should see the function exported with a mangeled name and that is the name that you woudl have to specify to VB
To fix this problem, you can specify the mangeled name to VB, or--better--declared the function as "extern "C" ". This dissables name mangeling on the function.
Let me know if you have questions.