Results 1 to 3 of 3

Thread: calling DLL function

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    3

    Post

    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
    ------------------------


  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    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
    [email protected]
    smalig.tripod.com

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    3

    Post

    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
    ------------------------


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width