Solved

Using MS DLLs in BORLAND

Posted on 1997-12-22
2
458 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 nested-loops in the C programming language.

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now