Results 1 to 2 of 2

Thread: bad DLL calling convenction.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    bad DLL calling convenction.

    I have exported two C++ functions into a dll.

    int getNumber1(){return 9;};
    int getNumber2(int a){return a;};




    VB Code:
    1. 'Declaration
    2. Public declare function getNumber1() Lib "C:\Link5.dll" () as Long
    3. Public declare function getNumber2() Lib "C:\Link5.dll" (Byval a as Long) as Long
    4.  
    5.  
    6. 'Usage
    7. Msgbox (getNumber1)
    8. Msgbox (getNumber2(5))

    The program displays a msgbox with number 9 as returned by the first function. But the 2nd statement produces an error "Bad DLL calling convention".
    What seems to the error here?

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: bad DLL calling convenction.

    Code:
    Private Declare Function getNumber1 Lib "C:\Link5.dll" () As Long
    Private Declare Function getNumber2 Lib "C:\Link5.dll" (ByVal a As Long) As Long
    Code:
    extern "C" __declspec( dllexport ) __stdcall int getNumber2(int);
    
    extern "C" __declspec( dllexport ) __stdcall int getNumber2(int a)
    {
           return a;
    
    
    };

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