Calling DLL written in Borland C++ V4.0 
Author Message
 Calling DLL written in Borland C++ V4.0

I'm trying to call a DLL wrtten with Borland C++, but I'm not having any
luck.  VB says it can't find the function (I've tried changing the name
of the DLL, and then it says it can't find that - so it's not that).

I'm compiling 32 bit.

Can anyone help please?  Replies by email if poss.

Here's the code:-

#define  STRICT
#include <windows.h>
#pragma hdrstop

// Turn off warning: Parameter '' is never used
#pragma argsused

// Every DLL has an entry point LibMain || DllEntryPoint
// and an exit point WEP.
#if defined(__FLAT__)
BOOL WINAPI DllEntryPoint( HINSTANCE hinstDll,
                                                                        DWORD fdwRreason,
                                                                        LPVOID plvReserved)
#else /* not flat model  */
int FAR Pascal LibMain( HINSTANCE hInstance,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine )
#endif /* __FLAT */
{
#ifndef  __FLAT__

// The startup code for the DLL initializes the local heap(if there is
one)
// with a call to LocalInit which locks the data segment.

         if ( wHeapSize != 0 )
                  UnlockData( 0 );
#endif
         return 1;   // Indicate that the DLL was initialized successfully.

Quote:
}

// Turn off warning: Parameter '' is never used
#pragma argsused

int FAR PASCAL WEP ( int bSystemExit )
{
         return 1;

Quote:
}

int FAR _export multiply(int number)
{
        int result;

        result=number*2;
        return(result);

Quote:
}



Sat, 05 Feb 2000 03:00:00 GMT  
 Calling DLL written in Borland C++ V4.0

Quote:

> I'm trying to call a DLL wrtten with Borland C++, but I'm not having any
> luck.  VB says it can't find the function (I've tried changing the name
> of the DLL, and then it says it can't find that - so it's not that).
[snip]
> int FAR _export multiply(int number)
> {
>         int result;

>         result=number*2;
>         return(result);
> }

You need to make sure you use the stdcall convention for 32-bit DLL
functions. Also, remember that function names are case-sensitive in the
32 bit world. Finally, I'm not familiar with Borland C++, but if the int
data type is 4 bytes, you have to use LongInt's in VB for compatibility.

--
============
Robert Powers

ANTI-SPAM: replace **** with robert for email address
Opinions mine, not my employer's



Sat, 05 Feb 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. visual basic 4.0 call to borland c++ 5.0 dll

2. Create borland c++ dll and call from vb

3. VB4 calls Borland C++ generated DLL

4. Writing VBXs with Borland C++ 3.1

5. Help Calling a DLL Written in C++

6. From VB calling Dll's written in C++

7. How to write Visual C++ DLL's and call them from Visual Basic

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

9. Problem with VB 4.0 using dll created with borland c++

10. DLL: Borland C++ 4.52 to Visual Basic 4.

11. Problem reading a file using Borland C++ dll with VB4

12. HELP: Creating DLL for VB using Borland C/C++

 

 
Powered by phpBB® Forum Software