Bad DLL calling convention (error 49) 
Author Message
 Bad DLL calling convention (error 49)

Hi,

I am trying to call a DLL function that I wrote in C++ and I keep getting
error 49 - Bad DLL calling convention. The DLL function expects a pointer to
a null terminated string and returns an integer.

extern "C" __declspec(dllexport) int SetStreamDate(char *date)
{
    ...
    return 10;

Quote:
}

This is how i declared the DLL function in VB:
Private Declare Function SetStreamDate Lib MyLib.dll" (ByVal mDate As
String) As Long

The function is called in the following way:

Dim mDate As String
...
mDate = Format(Now, "yyyy-mm-dd")
k = SetStreamDate(ByVal mDate)

The problem is that when I am debugging the application I get error 49 on
the line that calls the DLL function whereas if i compile the app into an
exe there is no problem at all. (I have no problem calling any other DLL
function from the same DLL).

Thanks
Ioannis



Tue, 08 Jun 2004 21:37:09 GMT  
 Bad DLL calling convention (error 49)
1) are you sure that you are using the StdCall parameter passing
convention for getting the parameters in C ?

2) If it works when compiled, but not in the IDE then have you checked
that you do not have *two* copies of the DLL - VB is a bit dim about
this - it searches different paths in the IDE than in compiled mode.

3) Watch out for regional variations from Format - it is horribly
locale aware.

On Fri, 21 Dec 2001 15:37:09 +0200, "Ioannis Demetriades"

Quote:

>Hi,

>I am trying to call a DLL function that I wrote in C++ and I keep getting
>error 49 - Bad DLL calling convention. The DLL function expects a pointer to
>a null terminated string and returns an integer.

>extern "C" __declspec(dllexport) int SetStreamDate(char *date)
>{
>    ...
>    return 10;
>}

>This is how i declared the DLL function in VB:
>Private Declare Function SetStreamDate Lib MyLib.dll" (ByVal mDate As
>String) As Long

>The function is called in the following way:

>Dim mDate As String
>...
>mDate = Format(Now, "yyyy-mm-dd")
>k = SetStreamDate(ByVal mDate)

>The problem is that when I am debugging the application I get error 49 on
>the line that calls the DLL function whereas if i compile the app into an
>exe there is no problem at all. (I have no problem calling any other DLL
>function from the same DLL).

>Thanks
>Ioannis



Tue, 08 Jun 2004 23:12:59 GMT  
 Bad DLL calling convention (error 49)
hi,

On Fri, 21 Dec 2001 15:37:09 +0200, "Ioannis Demetriades"

Quote:

>Hi,

>I am trying to call a DLL function that I wrote in C++ and I keep getting
>error 49 - Bad DLL calling convention. The DLL function expects a pointer to
>a null terminated string and returns an integer.

>extern "C" __declspec(dllexport) int SetStreamDate(char *date)

use
extern "C" __declspec(dllexport) int __stdcall SetStreamDate(char
*date);

and declare
SetStreamDate
in the .def file of your C++ project

BR,
Kristof Meirlaen

--
Is your server up? Are you sure?
Monitor your servers:
http://www.kri-soft.be/servermonitor/



Wed, 09 Jun 2004 02:27:59 GMT  
 Bad DLL calling convention (error 49)
Wrong declaration of the exported functions!
VB does not support DLL functions declared with __declspec(dllexport) . It
can access the functions but it you start adding arguments to the DLL
functions, those arguments will not be pushed in/popped out of the stack
correctly.

This is the correct function declaration in VC++ (so that the functions can
be accessed correctly from VB)
int __stdcall SetStreamDate(char *date)



Wed, 09 Jun 2004 17:27:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Run-time error '49': Bad DLL calling convention

2. Error 49: Bad Dll Calling convention

3. Help Re: error 49 Bad DLL calling convention

4. Error 49 -- Bad DLL Calling Convention

5. error 49 - bad dll calling convention

6. Bad Calling Convention error 49 - due to calling a Sub in a .bas module

7. Possible answer to Err 49: Bad DLL calling convention

8. Possible answer to Err 49: Bad DLL calling convention

9. RunTime 49: Bad DLL Calling Convention

10. error 49 - Bad DLL callling convention

11. EnumThreadWindows gives error: "Bad DLL calling convention (Error 49)"

12. Help! Bad DLL Convention(49)

 

 
Powered by phpBB® Forum Software