problem: vc++ dll and vb 
Author Message
 problem: vc++ dll and vb

Hi, got a problem with calling a simple c++ dll from vb, always got error
"bad calling convention", all param-types seem to be correct :(

any ideas ?

thx, Lasse
---------------------------------------------

begin 666 dlltest.zip
<encoded_portion_removed>



Thu, 20 Dec 2001 03:00:00 GMT  
 problem: vc++ dll and vb
Did you declare your C functions with  _stdcall ???



Quote:
> Hi, got a problem with calling a simple c++ dll from vb, always got error
> "bad calling convention", all param-types seem to be correct :(

> any ideas ?

> thx, Lasse
> ---------------------------------------------



Thu, 20 Dec 2001 03:00:00 GMT  
 problem: vc++ dll and vb
Don't post binary Zip files to the newsgroup when all you've got is 3 simple
files of source code.  Paste in your message or on a web page in text.
Viruses are spread by binaries and most people probably won't even look at
your problem because of that.

Anyway, I know nothing about C++.  However, if I were you, I wouldn't
delcare the function in Visual Basic with Alias "#3".  I'm not sure a
function can be called that way.  Instead, use the actual name of the
function.  I'm not sure, but from your C source, it looks like you are
actually trying to run "myDllFunc" or something like that.

--
Howard Henry 'Gawyn Ballpeen' Schlunder
Gawyn Developments; Core developer
http://venus.ajusd.org/~hschlund/



Thu, 20 Dec 2001 03:00:00 GMT  
 problem: vc++ dll and vb
I have the same problem when I try and pass more than one variable

ie:

this works:

DLL(mydll):

#include <stdio.h>

#define DllExport __declspec( dllexport )
extern "C" DllExport long myfun(long x);
extern "C" DllExport long myfun(long x)
{
return (x + 200);

Quote:
}

//  this passes a value from VB as x to this VCpp 5.0 dll (w/
//_stdcall). then returns x + 200 to VB as a long.

VB part:

    Private Declare Function myfun Lib _
        "C:\temp\mydll.dll" _

        (ByVal x As Long) As Long

But this one does not work for me.

DLL2(mydll)::

#include <stdio.h>

#define DllExport __declspec( dllexport )
extern "C" DllExport long myfun(long x, long y);
extern "C" DllExport long myfun(long x, long y)
{
return (x + y + 200);

Quote:
}

//  this passes 2 values from VB as x & y  to this VCpp 5.0 dll (w/
//_stdcall). then should returns x +  y + 200 to VB as a long.  But I
get the dll does not support this function....

VB part:

    Private Declare Function myfun Lib _
        "C:\temp\mydll.dll" _

        (ByVal x As Long, ByVal y As Long) As Long

I hope this helps..  I am stuck also, but only when there are more
than one variable to pass..

If you like I can post explicit directions how to make the DLL..

Garrett



Quote:
>Did you declare your C functions with  _stdcall ???




>> Hi, got a problem with calling a simple c++ dll from vb, always got error
>> "bad calling convention", all param-types seem to be correct :(

>> any ideas ?

>> thx, Lasse
>> ---------------------------------------------



Thu, 20 Dec 2001 03:00:00 GMT  
 problem: vc++ dll and vb
ok..  here is the fix:

DLL2(mydll)::

#include <stdio.h>

#define DllExport __declspec( dllexport )
extern "C" DllExport long myfun(long x, long y);
extern "C" DllExport long myfun(long x, long y)
{
return (x + y + 200);

Quote:
}

//  this passes 2 values from VB as x & y  to this VCpp 5.0 dll (w/
//_stdcall). then should returns x +  y + 200 to VB as a long.  But I
get the dll does not support this function....

VB part:

****  here is the problem.  for 2 longs that is 8 bytes long not 4!

    Private Declare Function myfun Lib _
        "C:\temp\mydll.dll" _

        (ByVal x As Long, ByVal y As Long) As Long

hope this helps..

Garrett


Quote:

>DLL2(mydll)::

>#include <stdio.h>

>#define DllExport __declspec( dllexport )
>extern "C" DllExport long myfun(long x, long y);
>extern "C" DllExport long myfun(long x, long y)
>{
>return (x + y + 200);
>}

>//  this passes 2 values from VB as x & y  to this VCpp 5.0 dll (w/
>//_stdcall). then should returns x +  y + 200 to VB as a long.  But I
>get the dll does not support this function....

>VB part:

>    Private Declare Function myfun Lib _
>        "C:\temp\mydll.dll" _

>        (ByVal x As Long, ByVal y As Long) As Long



Thu, 20 Dec 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problems calling a VC DLL from VB

2. Problems passing Device Context handels from VB 4.0 to VC++2.0 DLL’s

3. Problem calling DLL writen in VC 5.0 from VB 5.0

4. VC 6 dll called from VB 5 problem

5. Problem calling DLL writen in VC 5.0 from VB 5.0

6. Problem calling DLL writen in VC 5.0 from VB 5.0

7. Problem calling DLL writen in VC 5.0 from VB 5.0

8. Need help passing a DC handle from vb to a vc++ dll

9. Calling VC++ programs and VC created dlls from VB

10. use dlls created with vc++ in vb

11. VB5 and VC++6 DLL problems

12. Problem with VB5 and VC MFC-DLL

 

 
Powered by phpBB® Forum Software