Re: dll won't work with VB6
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Wed, 11 Jun 2008 13:12:37 -0500
Igor Tandetnik wrote:
Dave Cullen <none@xxxxxxxx> wrote:
I have created a DLL using VS8 C++. It works fine when the functions
are called from a C++ application but not from a VB6 app.
Functions in the dll are declared like this:
extern "C" __declspec(dllexport) int DLL_Init(int port1,int port2 =
NULL)
The VB declaration is like this:
Declare Function DLL_Init Lib "MfDfDLL.dll" (ByVal port1 As Long,
ByVal port2 As Long) As Long
The error I get under VB is Runtime error 49, "Bad DLL calling
convention".
VB can only call exported functions that use __stdcall calling
convention.
I thought there was a CDecl keyword you could tag on the Declare Function
line, but __stdcall is definitely the default, and also the convention used
by the entire Win32 API. In fact, typically you'd use the WINAPI macro on
the C prototype.
.
- References:
- dll won't work with VB6
- From: Dave Cullen
- Re: dll won't work with VB6
- From: Igor Tandetnik
- dll won't work with VB6
- Prev by Date: Re: Problem with using char* to return string by reference
- Next by Date: Re: Problem with using char* to return string by reference
- Previous by thread: Re: dll won't work with VB6
- Next by thread: Email address validation?
- Index(es):
Relevant Pages
|