Calling a function in Visual C DLL results in not found msg 
Author Message
 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)



Fri, 20 Aug 1999 03:00:00 GMT  
 Calling a function in Visual C DLL results in not found msg

Did you declare the functions and corresponding ordinals in the .DEF file?



Quote:
> 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;
> }

> NOMANGLE short CCONV PassInteger (short intgr, short far *pintgr)
> {
>    *pintgr = intgr;
>    return intgr + 1;
> }

> NOMANGLE short CCONV PassBoolean (short bln, short far *pbln)
> {
>    *pbln = ~bln;
>    return bln;
> }

> NOMANGLE LONG CCONV PassLong (LONG lng, LPLONG plng)
> {
>    *plng = lng;
>    return lng + 1;
> }

> NOMANGLE float CCONV PassSingle (float sng, float far *psng)
> {
>    *psng = sng;
>    return sng + (float)1.99;
> }

> NOMANGLE double CCONV PassDouble (double dbl, double far *pdbl)
> {
>    *pdbl = dbl;
>    return dbl + 1.99;
> }

> 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)



Sun, 22 Aug 1999 03:00:00 GMT  
 Calling a function in Visual C DLL results in not found msg

Quote:

>Did you declare the functions and corresponding ordinals in the .DEF file?

He also needs to NOT use declspec().  I just declare them WINAPI and
add the exports to the def file, like you say.

Quote:
>> #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

Bruce


Sun, 22 Aug 1999 03:00:00 GMT  
 Calling a function in Visual C DLL results in not found msg

Hi Keith,

   Thanks for taking time to lend a hand. Yes, I did create a .DEF file
(included below) though I'm not sure how or who uses it or what directory
it should be in. Can you explain how it fits into the picture?


returned as undeliverable.

Thanks.....David

;******* Visual Basic Utilities Program Definition File (.DEF)  ********
;
;  The module definition file supplies extra information about the program
;  module to the LINKER.
;
;  Different HEAPSIZE used. ( 1024 bytes )

NAME    VBUTILS

DESCRIPTION 'VbUtils Program'

CODE  PRELOAD MOVEABLE DISCARDABLE
DATA  PRELOAD MOVEABLE MULTIPLE

HEAPSIZE    1024
STACKSIZE   5120
; All functions that will be called by any Windows routine
; MUST be exported.

EXPORTS








Quote:
> Did you declare the functions and corresponding ordinals in the .DEF
file?



> > 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;
> > }

> > NOMANGLE short CCONV PassInteger (short intgr, short far *pintgr)
> > {
> >       *pintgr = intgr;
> >       return intgr + 1;
> > }

> > NOMANGLE short CCONV PassBoolean (short bln, short far *pbln)
> > {
> >       *pbln = ~bln;
> >       return bln;
> > }

> > NOMANGLE LONG CCONV PassLong (LONG lng, LPLONG plng)
> > {
> >       *plng = lng;
> >       return lng + 1;
> > }

> > NOMANGLE float CCONV PassSingle (float sng, float far *psng)
> > {
> >       *psng = sng;
> >       return sng + (float)1.99;
> > }

> > NOMANGLE double CCONV PassDouble (double dbl, double far *pdbl)
> > {
> >       *pdbl = dbl;
> >       return dbl + 1.99;
> > }

> > 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)



Mon, 23 Aug 1999 03:00:00 GMT  
 Calling a function in Visual C DLL results in not found msg

Quote:

> Hi Keith,

>    Thanks for taking time to lend a hand. Yes, I did create a .DEF file
> (included below) though I'm not sure how or who uses it or what directory
> it should be in. Can you explain how it fits into the picture?


> returned as undeliverable.

> Thanks.....David

> ;******* Visual Basic Utilities Program Definition File (.DEF)  ********
> ;
> ;  The module definition file supplies extra information about the program
> ;  module to the LINKER.
> ;
> ;  Different HEAPSIZE used. ( 1024 bytes )

> NAME    VBUTILS
> David -

In the above line, try changing NAME to LIBRARY

Mike Reublin



Wed, 25 Aug 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How do you call a Visual C++ (DLL) function from Visual Basic

2. Calling Visual C++ 5.0 DLL Functions From Visual Basic 5.0

3. To Call or not to Call - test results

4. path not found / illegal function call errors

5. API call gives COMMDLG.DLL not found

6. calling a dll in vb3 : file not found

7. Calling VB5 DLL with another VB5 DLL results in crashes

8. error 53 (file not found) with external DLLs called from COM or EXE

9. Error: pdsodbc.dll not found, 20532 cannot find database dll

10. File Not Found on a call to a DLL

11. File not found (VB6 calling DLL in XP)

12. Calling a DLL gives "File Not Found", but File Exists

 

 
Powered by phpBB® Forum Software