You are on page 1of 2

Calling 32-bit DLL's built with Borland C++ from non-BC Apps

============================================================
Currently, Borland C++ supports calling a DLL compiled with Borland C++ from
applications created with other tools only if they are dynamically bound to the
DLL. This is achieved by the application calling LoadLibrary at run-time to load
the DLL and then calling GetProcAddress to retrieve the entry points for the
functions exported from the DLL.
Static binding is not supported. From a C or C++ application, static binding is
achieved by linking import records (either import libraries or entries in the
IMPORTS section of the application's Module Definition File) to the calling
application. Using Delphi 2.0, static binding is achieved using a declaration
such as:
function Foo(parm: Integer): Integer; stdcall; external 'my.dll' name 'Foo';
You can use either C++ or Structured Exception Handling in the DLL. For best
results, exceptions should be caught within the scope of the DLL throwing the
exception. If the calling application is built with Borland C++, Delphi or
Microsoft Visual C++, the exception can be caught in the application calling the
DLL; however, Visual Basic does not seem to have an exception handlng syntax.
To create an EH-compatible 32-bit DLL, just replace the default startup code,
c0d32.obj for 32-bit DLL's, with c0d32dyn.obj and re-link the DLL. Using
command-line tools, the startup code is the first object module specified to
Tlink32. Using the Integrated Development Environment, select Options |
Environment | Project View and check Show run-time nodes. In the project window,
there will now be displayed entries for the startup module and all the libraries
which are automatically linked in depending on your target. Remove the node for
the startup code, c0d32.obj, and add c0d32dyn.obj in its place.
List of files
=============
README.TXT
- This file
C0D32DYN.OBJ - Startup for building compatible DLL's
BCDLL.CPP
BCDLL.H
BCDLL.DEF
BCDLL.DLL
MAKEDLL.MAKE

Source and built DLL to be called


Header file for the DLL and C/C++ consumers
Module definition file
Built version of the DLL
Makefile for building the test DLL

CTOBC.CPP
CTOBC.RC
CTOBC.RH
HANDSHAK.BMP
HANDSHAK.ICO

C++ source for a test application calling BCDLL


Dialog resource
Resource header file
Main window bitmap
Application icon

MAKEBC.MAK
BCTOBC.EXE
MAKEVC.MAK
VCTOBC.EXE

Makefile for building CToBC with Borland C++


CToBC built with Borland C++
Makefile for building CToBC with Microsoft Visual C++
CToBC buiilt with Microsoft Visual C++

DELPHI2C.DPR
DELPHI2C.EXE
MAIN.DFM
MAIN.PAS

Delphi 2.0 project for a test application calling BCDLL


Built version of Delphi2C test application
Form resource
Pascal source for Delphi2C application

VBTOC.EXE
VBTOC.FRM

- Visual Basic 4.0 project for a test application calling BCDLL


- Form resource

VBTOC.MAK
VB40032.DLL

- Project file
- Visual Basic run-time library

You might also like