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

Run time error 49

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US

This is a strange problem. If I run the VB6 program from the IDE it generates a run time error 49, bad DLL calling convention. However, if I compile the VB6 program and run the .exe file it does not generate the error.

The VB declare statement in a module:
Code:
Public Declare Function LogOnToTelnet(ByVal cIP As String,
                                      ByVal iPort As Integer,
                                      ByVal cPrompt As String,
                                      ByVal cUsername As String,
                                      ByVal cPassword As String) As Integer

The calling statement in a form (which generates the error):
Code:
iRet = LogInToTelnet(cIP, iPort, cPrompt, cUsername, cPassword)

And the function in VC++6
Code:
extern "C" DLLexport int LogInToTelnet(char* cIP,
                                       int   nPort,
                                       char* cPrompt,
                                       char* cUsername
                                       cahr* cPassword)
{

 .....

}
Any ideas on this one?

thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 

Nope. Long integers did not work. Even so, why would the compiled VB6 work but not from the IDE?

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Is this a typo?
Code:
cahr* cPassword

If not change to char....

Money can't buy happiness -- but somehow it's more comfortable to cry in a Corvette than in a Yugo.
 

Sorry, it was a typo. I do have some new info. If I call the function in the DLL without any parameters, it does go to the DLL function and I get a return. This is without changing the DLL. That means if I do nothing to the DLL, but at the VB end I change the declare statement to reflect no parameters and make the call with no parameters, the DLL function is called and it returns a value based on nothing coming in. What does the IDE do that is different from the compiled exe file?

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

Part and Inventory Search

Sponsor

Back
Top