简体   繁体   中英

DLL Export C/C++ 6.00 function invoked by VB6

I have been attemptng to create a DLL with C/C++ that can be accessed by VB6, and that's right I get error "453 Can't find DLL entry point myFunctionName in myDllName.dll" upon calling the function from a VB6 app. After searching the Web, including this site, I see that I am not alone, and I have tried the various solutions posted but error "453" is unexcapable. This is Not a COMM dll, and I believe that is possible when created via C/C++. In any case, please help, if you can. Please refer to the following simple test case below:

The DLL created as a C/C++ 6.00 Win32 Dynamic-Link Library:

#include <Windows.h>   

// Note that I did try the line below rather than the def file, but to no avail...  
// #pragma comment(linker, "/EXPORT:ibask32=_ibask32@0")

// Function definition   
extern "C" int __declspec(dllexport) __stdcall ibask32()   
{   
    MessageBox(NULL,"String","Sample Code", NULL);   
    return 0L;   
}   

The def file:

LIBRARY "Gpib-32"
EXPORTS   
ibask32

Now for the VB App:

The following is the entire content of the startup Form1, Form_Load

Option Explicit
 Private Sub Form_Load()
  Call ibask
 End Sub

The following is a BAS module file that is added to the project:

Option Explicit

Declare Function ibask32 Lib "Gpib-32.dll" Alias "ibask" () As Long

Sub ibask()

    Call ibask32   ' Note: This is the point of failure

End Sub

Thanks in advance if a workable solution can be provided, Tom

You are doing everything right as near as I can tell. Verify your assumptions by running Dumpbin.exe /exports on the DLL. That shows the actual name of the exported function, it has to match the Alias in the VB6 declaration.

The only other failure mode I can think of is VB6 loading the wrong DLL. It has to be present in a directory listed on the PATH if you want to use it from the VB6 IDE. Verify by running "where gpib-32.dll" from the command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM