Can't find the DLL entry point

G

Guest

I use the C++.NET to write a dll and call the dll using VB6

VC++ Code

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserve


return TRUE


BOOL APIENTRY DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserve


return TRUE


__declspec(dllexport) long SPS_Hello ( char *msg

if ( msg

strcpy ( msg, "Hello !!" )
return 0

els

return 1



VB code

Declare Function SPS_Hello Lib "SPS.dll" (msg As String) As Lon

Sub main(
Dim temp As Strin

SPS_Hello (temp
MsgBox temp

End Su

I run the VB and get an error: "Can't find DLL entry point SPS_Hello in sps.dll". I have the entry point function "DllMain". What is wrong

S.N. Yan
03/29/2004
 
W

William DePalo [MVP VC++]

S.N. Yang said:
I use the C++.NET to write a dll and call the dll using VB6.

VC++ Code:
...
__declspec(dllexport) long SPS_Hello ( char *msg )
{
if ( msg )
{
strcpy ( msg, "Hello !!" ) ;
return 0 ;
}
else
{
return 1 ;
}
}

VB code:

Declare Function SPS_Hello Lib "SPS.dll" (msg As String) As Long

Sub main()
Dim temp As String

SPS_Hello (temp)
MsgBox temp1

End Sub

I run the VB and get an error: "Can't find DLL entry point SPS_Hello in
sps.dll". I have the entry point function "DllMain". What is wrong?

Open up a command window (aka "DOS" box), navigate to the directory that
contains your DLL and type

dumpbin /exports SPS.dll

The command will list the names of the functions that you export. Now if the
name of your export is not SPS_Hello but rather xxxSPS_Helloyyy, then create
a module definition file

LIBRARY SPS

DESCRIPTION 'whatever you like

EXPORTS

SPS_Hello = xxxSPS_Helloyyy

Then add the module definition file to your project and relink.

There are other ways of solving the export naming problem but this one
allows the DLL to be used easily by C/C++/VB/etc clients

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top