Mike Larson
9/15/2011 3:22:00 PM
Thanks for the replies.
DEMO_API is as follows
#define DEMO_API __declspec(dllexport)
DEMO_API BOOL GetVoltage(DWORD voltType, float *retval, DWORD
*typeSupport = NULL);
One thing I notice now is that the prototypes in the .h file don't use
_stdcall.
The source file that was available was written in C# (i think). It's
usages of the function is :
public unsafe static extern bool GetVoltage(UInt32 voltType,
float* retval, UInt32* typeSupport);
I have another DLL I created that I can use to make a wrapper, but I
was hoping for the direct approach.
Thanks.
Mike
On Sep 15, 9:45 am, Tom Shelton <tom_shel...@comcast.invalid> wrote:
> Mike formulated the question :
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > I am trying to use a DLL provided by a hardware/software manufacturer
> > in VB6. The manufacture has not provided example files for VB6 (only
> > for VS.NET version) and I would have to pay them to create these
> > files.
>
> > My problem is that they have a function in the DLL I want to use but I
> > can't seem to declare it correctly in my VB6 module, I keep getting a
> > "Bad DLL Calling Convention" error.
>
> > Here is the function from the header file
>
> > DEMO_API BOOL GetVoltage(DWORD voltType, float *retval, DWORD
> > *typeSupport = NULL);
>
> > My first shot at the Declare statement doesn't work.
>
> > Public Declare Function GetVoltage Lib "C:\MyDemo\Demo.dll" (ByVal
> > voltType As Long, ByRef retval As Single, ByRef typeSupport As Long)
> > As Boolean
>
> I might change the return value to Long rather than Boolean and try
> that first... The BOOL type is usually a typedef for int, which is
> 32-bit and the VB6 size is 16-bit internally. It's possible, but not
> likely that there is a stack imbalance going on here?
>
> Having the definition of DEMO_API or a look at the .net version of the
> declare would clear this up a bit - because the likely answer is as
> Deanna indicated. C++ will default to cdecl - and vb6 doesn't handle
> that calling convention natively.
>
> If it is the case that the call is cdecl, than Mayayana might be able
> to help you out here with some code to wrap the call. There is a class
> that he was using to make some of these types of calls a while back...
>
> --
> Tom Shelton