calling dll trouble 
Author Message
 calling dll trouble


I wish to call a dll from within VB.  I've created the dll in C++ and
can't seem to call it appropriately.  I get this error

Bad DLL calling convention.

Declare Function diskfree Lib "diskfree.dll" (ByVal num As Integer) As

Public Function callM20()
    Call diskfree(2)
End Function

It is finding the diskfree.dll but doesn't seem to recognize the
function, which I think has something do to with how I'm setting up the
dll for export. (Perhaps this is more of a C++ question, but I can make
it work from within C++). My dll has only one function call in the
source file:

        int diskfree(int num);
        int diskfree(int num)
                return ( num * 20 );

        I've not included a header file because it is so short.  My def file
looks like this.

        LIBRARY    "diskfree"
        DESCRIPTION 'Implements a binary tree.'

I know this may be a more appropriate question for a C++ list, but I
thought I would try it out here.



Mon, 17 Jul 2000 03:00:00 GMT  
 calling dll trouble


>I wish to call a dll from within VB.  I've created the dll in C++ and
>can't seem to call it appropriately.  I get this error

>Bad DLL calling convention.

Since you didn't specify, I'm going to assume you are using 32-bit Windows.

In that case, a C integer is a Long in VB and the argument and return value
should be so declared in your VB code.

In addition, try declaring your C function as:

    int WINAPI diskfree(int num);

Jonathan Wood
SoftCircuits Programming

Tue, 18 Jul 2000 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Trouble calling custom dll functions from 2.0

2. Trouble with calling C dll...

3. Trouble calling a CA-VO 2.0 2b .dll from VB 5.0

4. Trouble in calling Dll-function from VB.

5. trouble calling a DLL from VB4

6. Calling DLL function troubles - please, please help!!!

7. CopyFileEx - Trouble with bad DLL calling convention...

8. Trouble calling to a DLL (Sean)

9. Trouble calling a DLL

10. 2 PRBS: Calling 16 bit DLL from VB5 and Bad DLL Calling Convention

11. VB 5.0 calling C++ 5.0 DLL that calls winsock.dll

12. All about API calls DLL calls


Powered by phpBB® Forum Software