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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find entry point in DLL

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US
I have a Regular DLL with MFC with an exported function. When I call this function from a VB program it gives the error 453 can't find entry point in the DLL. I have this code in the .h file:
Code:
#define DLLexport  __declspec(dllexport)

#ifdef __cplusplus
extern "C"
{
#endif

DLLexport int WINAPI SendCommand(int cCommand);

#ifdef __cplusplus
}
#endif
This is the code in the .cpp file:
Code:
DLLexport int WINAPI SendCommand(int nCommand)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	return 1;
}

In the VB code I have this as the declaration:
Code:
Public Declare Function SendCommand Lib "TelnetDLL" (ByVal cCommand As Integer) As Integer
And this is the code to call the function:
Code:
       Call SendCommand(2)

I put the .DLL and .LIB files in the system32 folder. I tried to register the .DLL and it said it loaded it but couldn't find the entry point for the DLL.
Any ideas would be greatly appreciated.

thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Use Alias clause in VB external function declarations.
Use VS Depends utility to see true names of external dll functions.
 

I found the solution. The __cplusplus was not defined in this DLL. Not sure where that is defined. But I took it out and used the following in the header file:

Code:
#define DLLexport __declspec(dllexport)
extern "C" DLLexport int SendCommand(int nCommand);

Then in the CPP file:
Code:
extern "C" DLLexport int SendCommand(int nCommand)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState())
  return 1;
}

Now this works. But I have another problem to solve. Time to get back to work.

Thanks for the reply.


HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top