
Calling a function in Visual C DLL results in not found msg
Hi,
I have written a C DLL that I call from VB4/32 and consistently get an
"error 453, specified DLL function not found" message. I am using the MS
Visual C++ 4.2 compiler for the DLL. I am certain that the problem is "name
decoration" or "name mangling" but I am unsure about how to correct it. I
have been through the VC++ Online Books but to no avail.The C code is the
sample in the VB4DLL.Txt file that comes with VB4. This file talks
specifically about this problem but either I'm thick-headed or it's not
very clear. At any rate I could use a hand in figuring this out. Since the
source is short I have included it.
Thanks in advance for any help you can offer.....David
The C code:
#include <windows.h>
#include <ole2.h>
#ifdef WIN32
#define CCONV _stdcall
#define NOMANGLE __declspec(dllexport)
#else
#define CCONV FAR Pascal _export
#define NOMANGLE
#include <stdlib.h>
#include <compobj.h>
#include <dispatch.h>
#include <variant.h>
#include <olenls.h>
#endif
NOMANGLE BYTE CCONV PassByte (BYTE byt, LPBYTE pbyt)
{
*pbyt = byt;
return byt + 1;
Quote:
}
NOMANGLE short CCONV PassInteger (short intgr, short far *pintgr)
{
*pintgr = intgr;
return intgr + 1;
Quote:
}
NOMANGLE short CCONV PassBoolean (short bln, short far *pbln)
{
*pbln = ~bln;
return bln;
Quote:
}
NOMANGLE LONG CCONV PassLong (LONG lng, LPLONG plng)
{
*plng = lng;
return lng + 1;
Quote:
}
NOMANGLE float CCONV PassSingle (float sng, float far *psng)
{
*psng = sng;
return sng + (float)1.99;
Quote:
}
NOMANGLE double CCONV PassDouble (double dbl, double far *pdbl)
{
*pdbl = dbl;
return dbl + 1.99;
Quote:
}
The VB code:
Private Declare Function PassLong Lib "c:\Source
Code\C\VbUtils\Debug\VbUtils.dll" (ByVal lng As Long, plng As Long) As Long
Dim l As Long, lr As Long
l = 99
l = PassLong(l, lr)