Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling exported C functions (DLL) in Visual Basic

Status
Not open for further replies.

buzznick

IS-IT--Management
Dec 29, 2004
39
US
Hi, I'm writing a DLL in C/C++ that needs to export a couple of functions to be used by a Visual Basic program. However, we're having some trouble getting the Visual Basic to read the exported C functions.

They are very simple functions, eg:

extern "C" __declspec(dllexport)
void test_get_string(LPSTR str)
{
strcpy(str,"Hello World!");
}

extern "C" __declspec(dllexport)
UINT test_get_number(void)
{
return 123456;
}

The problem is that I don't know VB at all but that's all my client uses. He says I'm not exporting the functions correctly in the DLL because he's getting a "453" error (whatever that is!).

It was my understanding that simple C functions (as above) inside a DLL could be called from VB no problem.

Is it something I did wrong or is the client doing something wrong? Either way, how do I fix it?

Many thanks!
 
---------------------------
Microsoft Visual Basic
---------------------------
Run-time error '453':

Specified DLL function not found
---------------------------
OK Help
---------------------------

Error 453 indicates that the function your client is calling is not exported by that name. You need to verify that your client is calling the correct function name as exported by your DLL.

You can also use Dependency Walker to examine the export table of your compiled DLL.
 
Probable something you already did, but I'll try it anyway:

Did you actually export the functions by name? Did you, for instance link a module definition file? Something like:

LIBRARY "YourDLL.DLL"

EXPORTS
YourFunction1 @1 PRIVATE
YourFunction2 @2 PRIVATE


Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top