PDA

Click to See Complete Forum and Search --> : calling DLL function


Garouppa
Nov 1st, 1999, 05:26 PM
Hi all,
i've created a small dll (in VC 6) with only one function :
__declspec(dllexport) void dcrp(int x) ;

and then i've declared it in a VB program :
Declare Sub dcrp Lib "crp2.dll" _
(ByVal x As Integer)

and when i call it i always get an error message " BAd Calling convention".

Please any clues ?

------------------
------------------------
Garouppa the unknown fish
------------------------

smalig
Nov 1st, 1999, 07:09 PM
You must declared x value as long in vb, because int type in c is 4 bytes and integer type in vb is 2 bytes only. And long type is 4 bytes.

------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)

Garouppa
Nov 1st, 1999, 07:44 PM
Thanx, in fact my problemn as i've discovered after is that when creating a new DLL via VC 6 , the exported functions are in _cdecl scheme, and to enable them to VB, the _stdcall scheme should be used.
the new problem now is that if you use the _stdcall, VC 6 no more exports your function, to avoid this, you have to add a .DEF file in your project and add the following lines :

EXPORTS
mypoorfunction


Thanx anyway !

------------------
------------------------
Garouppa the unknown fish
------------------------