I’ve got a Windows DLL that I wrote, written in C/C++ (all exported functions are ‘C’). The DLL works fine for me in VC++. I’ve given the DLL to another company who do all their development in VB. They seem to be having a problem linking to the functions. I haven’t used VB in ten years and I don’t even have it installed. What could be the problem?
I’ve declared all my public functions as follows:
#define MYDCC_API __declspec(dllexport) MYDCCL_API unsigned long MYDCC_GetVer( void); . . .
Any ideas?
Finally got back to this today and have it working. The answers put me on the right track but I found this most helpful:
http://www.codeproject.com/KB/DLL/XDllPt2.aspx
Also, I had a few problems passing strings to the DLL functions, I found this helpful:
http://www.flipcode.com/archives/Interfacing_Visual_Basic_And_C.shtml
By using
__declspecfor export, the function name will get exported mangled, i.e. contain type information to help the C++ compiler resolve overloads.VB6 cannot handle mangled names. As a workaround, you have to de-mangle the names. The easiest solution is to link the DLL file using an export definition file in VC++. The export definition file is very simple and just contains the name of the DLL and a list of exported functions:
Additionally, you have to specify the
stdcallcalling convention because that’s the only calling convention VB6 can handle. There’s a project using assembly injection to handle C calls but I guess you don’t want to use this difficult and error-prone method.