Run-time error '49' Bad DLL calling convention 
Author Message
 Run-time error '49' Bad DLL calling convention

Hi, All:

I am a beginner about DLL. I built a DLL by Visual C++ 6, and called by
Visual Basic 6.
If I call that DLL don't pass any parameter, it works well.
But, when I passed a parameter to that DLL, the error ?49?| would happen.
My code is below:

1.(No parameter, it's OK.)
Visual C++:
short GetPort(void)
{
    return 1;

Quote:
}

Visual Basic:

Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll" ()
As Integer

txtPort.Text = CStr(GetPort())

2. (Passing parameter, error ?49?|)
Visual C++:
short GetPort(int i)   {
     return i;

Quote:
}

Visual Basic:
Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll"
(ByVal i As Integer) As Integer

txtPort.Text = CStr(GetPort(3) + 1)

Any idea would be appreciate




Mon, 16 Jul 2001 03:00:00 GMT  
 Run-time error '49' Bad DLL calling convention
Hi
    Use WINAPI in the C function signatures...like...

        int WINAPI GetPort(int)

ItheG



Mon, 16 Jul 2001 03:00:00 GMT  
 Run-time error '49' Bad DLL calling convention
Hi Steven:

Quote:
>2. (Passing parameter, error ?49?|)
>Visual C++:
>short GetPort(int i)   {
>     return i;
>}

>Visual Basic:
>Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll"
>(ByVal i As Integer) As Integer

>txtPort.Text = CStr(GetPort(3) + 1)

I know very little about C++, but I suspect that an int in C++ is a Long in
VB?  Perhaps try this:

Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll"
(ByVal i As Long) As Integer

I suspect that a short is an integer in VB, but if the above does not work
then try using As Long.

Hope this helps,

Doug.



Mon, 16 Jul 2001 03:00:00 GMT  
 Run-time error '49' Bad DLL calling convention
You must conform to the convention used to handle parameters on the stack
expected by VB.

short __stdcall GetPort(void)
{
    return 1;

Quote:
}

should work fine.

Kim

Kim Major - Visual Basic MCP.
=============================================
Renaissance Computer Systems LTD.

An entity is in Third Normal Form if every non-key attribute
depends on the key, the whole key and nothing but the
key, so help me Codd.
=============================================

Quote:

>Hi, All:

>I am a beginner about DLL. I built a DLL by Visual C++ 6, and called by
>Visual Basic 6.
>If I call that DLL don't pass any parameter, it works well.
>But, when I passed a parameter to that DLL, the error !49!| would happen.
>My code is below:

>1.(No parameter, it's OK.)
>Visual C++:
>short GetPort(void)
>{
>    return 1;
>}

>Visual Basic:

>Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll" ()
>As Integer

>txtPort.Text = CStr(GetPort())

>2. (Passing parameter, error !49!|)
>Visual C++:
>short GetPort(int i)   {
>     return i;
>}

>Visual Basic:
>Private Declare Function GetPort Lib "c:\GetBinary\Debug\GetBinary.dll"
>(ByVal i As Integer) As Integer

>txtPort.Text = CStr(GetPort(3) + 1)

>Any idea would be appreciate





Mon, 16 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

2. RunTime 49: Bad DLL Calling Convention

3. Bad DLL calling convention (error 49)

4. Error 49: Bad Dll Calling convention

5. Help Re: error 49 Bad DLL calling convention

6. Error 49 -- Bad DLL Calling Convention

7. error 49 - bad dll calling convention

8. Bad DLL calling covention '49'

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

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

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

12. error 49 - Bad DLL callling convention

 

 
Powered by phpBB® Forum Software