DLL Calling Convention 
Author Message
 DLL Calling Convention

 I am making a DLL for use with VB 5.0.  One of my functions is defined as
follows:

int bpLogout(int ByPass)

When I use vb and pass this function an integer the function runs just fine
but VB errors out on me and says that

text2.text=bpLogout(1)

is a "Bad DLL Calling Convention".  Any ideas? In VB I have the function
declared as follows:

Declare Function bpLogout Lib "bpremote" (ByVal ByPass As Integer) As
Integer

Thanks!



Mon, 27 Mar 2000 03:00:00 GMT  
 DLL Calling Convention

You should define your function as:
int Pascal bpLogout(int ByPass)

Quote:

> I am making a DLL for use with VB 5.0.  One of my functions is defined as
>follows:

>int bpLogout(int ByPass)

>When I use vb and pass this function an integer the function runs just fine
>but VB errors out on me and says that

>text2.text=bpLogout(1)

>is a "Bad DLL Calling Convention".  Any ideas? In VB I have the function
>declared as follows:

>Declare Function bpLogout Lib "bpremote" (ByVal ByPass As Integer) As
>Integer

>Thanks!



Tue, 28 Mar 2000 03:00:00 GMT  
 DLL Calling Convention



Quote:
> int bpLogout(int ByPass)
> text2.text=bpLogout(1)

Your function returns a INT, but the text2.text expects a STRING.
so try this:
        text2.text = Str(bpLogout(1))


Tue, 28 Mar 2000 03:00:00 GMT  
 DLL Calling Convention

Quote:
>Declare Function bpLogout Lib "bpremote" (ByVal ByPass As Integer) As
>Integer

VB5 still uses 16 bit integers, try defining your routine to use Long
instead:

Declare Function bpLogout Lib "bpremote" (ByVal ByPass As Long) As
Long

Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.
http://www.bj.co.uk



Tue, 28 Mar 2000 03:00:00 GMT  
 DLL Calling Convention

Seems to be a common problem, Ive only just worked out how to get it to
work my self.  This is what I have done (Note I write a 32-Bit program
under VB 5.0, I think older versions of VB may use the pascal calling
convension instead of stdcall) -

*** In .cpp file >

#if defined (__cplusplus)
  #define DllImport extern "C" __declspec(dllimport)
  #define DllExport extern "C" __declspec(dllexport)
#else
 #define DllImport __declspec(dllimport)
 #define DllExport __declspec(dllexport)
#endif

 #define CCONV _stdcall

DllExport short CCONV Function(short nData)
{
        code ...

Quote:
}

**** If .def file add >

EXPORTS



Quote:
>  I am making a DLL for use with VB 5.0.  One of my functions is defined
as
> follows:

> int bpLogout(int ByPass)

> When I use vb and pass this function an integer the function runs just
fine
> but VB errors out on me and says that

> text2.text=bpLogout(1)

> is a "Bad DLL Calling Convention".  Any ideas? In VB I have the function
> declared as follows:

> Declare Function bpLogout Lib "bpremote" (ByVal ByPass As Integer) As
> Integer

> Thanks!



Tue, 28 Mar 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Bad DLL calling convention in my MFC (for VB) DLL

2. Bad DLL calling convention?

3. VC++ dll calling conventions

4. Bad dll calling convention

5. bad dll calling convention, on conversion from 16bit to 32 bit

6. Bad DLL calling convention?

7. DLL calling conventions

8. Bad DLL calling convention

9. Bad DLL calling convention

10. DLL Calling Convention

11. Bad DLL Calling Convention

12. VC6 DLL calls VB6 DLL calls back to VC6 DLL: Occasional GPF or ‘Bad DLL calling convention'

 

 
Powered by phpBB® Forum Software