Solved

Using MS DLLs in BORLAND

Posted on 1997-12-22
2
465 Views
Last Modified: 2008-02-07
I know that there is a lot of threads on this subject and I'm sure I've
read them all but I am still unable to get the MS DLL to work within a
BC++ form/application.  I am able to convert the COF -> OMF via the
modified .DEF file and create a .LIB.  This .DLL compiles at all stages
with no complaints BUT when the program is executed it complains that it
is not an NT executable even without a single function call to the
library has been made!!!!

********** SAMPLE CODE and PROCEDURE **********

**** MICROSOFT Definations used to create DLL:
extern "C" {
        __declspec(dllexport) int __stdcall OpenDB(char *DBName);
        __declspec(dllexport) int __stdcall CloseDB(void);
        __declspec(dllexport) int __stdcall OpenSQL(void);
        __declspec(dllexport) int __stdcall CloseSQL(void);
        __declspec(dllexport) HENV __stdcall henvGet(void);
        __declspec(dllexport) HDBC __stdcall hdbcGet(void);
}


**** BORLAND SIDE:
**** IMPDEF CREATES DBCONNECT.DEF:
LIBRARY     DBCONNECT.DLL

EXPORTS
    _CloseDB@0                    =_CloseDB                       @1
    _CloseSQL@0                   =_CloseSQL                      @2
    _FetchNext@0                  =_FetchNext                     @3
    _OpenDB@4                     =_OpenDB                        @4
    _OpenSQL@0                    =_OpenSQL                       @5
    _SelectSQL@8                  =_SelectSQL                     @6
    _hdbcGet@0                    =_hdbcGet                       @7
    _henvGet@0                    =_henvGet                       @8
    _hstmtGet@0                   =_hstmtGet                      @9

**** MODIFIED TO:
LIBRARY     DBCONNECT.DLL

EXPORTS
    _CloseDB@0                    =_CloseDB                       @1
    _CloseSQL@0                   =_CloseSQL                      @2
    _FetchNext@0                  =_FetchNext                     @3
    _OpenDB@4                     =_OpenDB                        @4
    _OpenSQL@0                    =_OpenSQL                       @5
    _SelectSQL@8                  =_SelectSQL                     @6
    _hdbcGet@0                    =_hdbcGet                       @7
    _henvGet@0                    =_henvGet                       @8
    _hstmtGet@0                   =_hstmtGet                      @9

IMPORTS
    CloseDB=DBCONNECT._CloseDB@0
    CloseSQL=DBCONNECT._CloseSQL@0
    FetchNext=DBCONNECT._FetchNext@0
    OpenDB=DBCONNECT._OpenDB@4
    OpenSQL=DBCONNECT._OpenSQL@0
    SelectSQL=DBCONNECT._SelectSQL@8
    hdbcGet=DBCONNECT._hdbcGet@0
    henvGet=DBCONNECT._henvGet@0
    hstmtGet=DBCONNECT._hstmtGet@0

**** IMPLIB CREATES DBCONNECT.LIB

**** Insert into project with the following:
USEDEF("DBConnect.def");
USELIB("DBConnect.lib");

**** Compile as release.

**** Execute program:

!!!!!!!!!!!! Message complains that it is not a an NT
Executable!!!!!!!!!!!!


HELP
Paul
0
Comment
Question by:wang_paul
2 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1256826
First be sure your DLL is regular DLL and not MFC extension DLL since extension DLL works only with MFC application.
Then try to load DLL dinamically and obtain  function addresses. If it woks try to create lid file from DLL using importlib utility instead of VC++ linker.
0
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1256827
This is a nasty problem since Borland and MS use different and incompatible C++ name decoration schemes.  My advice is to forget using the exported names and call the DLL exported function by their ordinals instead.  This will work regardless of the produces of the DLL.  It's a bit more work up front but will work in all cases.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question