Using C DLLs

Posted on 1997-05-18
Last Modified: 2010-04-04
I now beleive thet the problem i described accured
because i made a 32bit DLL and tried to use it with DELPHI 1.0
which is 16 bit.

After making a 16 bit DLL, i keep getting , at run time, when
DELPHI is trying to LINK the DLL, a "can't find file" message.

The code looks like thet:

  function CreateDiffJpeg (a : Integer):Integer;
    { Private declarations }
    { Public declarations }


  Form1: TForm1;

  index : integer;


{$R *.DFM}
function CreateDiffJpeg ;  external 'diffjpeg.dll' index 1;

procedure TForm1.Button1Click(Sender: TObject);

     index := index +1;



Any idea ?
Question by:gur
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 1336433
You should post the relevent code, so we can see what you might me doing wrong.


Accepted Solution

GWalter earned 100 total points
ID: 1336434
In the Delphi Program link the dll-call like this:function ComInit (Handle: Integer): Integer; cdecl; extern "testdll.dll" index 12;
It is very import to supply the index, I couldnt manage to linka DLL with the Name. You can get the Index e.g. in B C++ 5.0by using IMPDEF. Now you can read the indexes in the .DEF file.! Indexes may change when recompiling the program.* cdecl =>  C-Stack-Handling

In the C++- DLL:
Declaration as folowing:
#ifdef __WIN32_DLL__
  #define exp __declspec(dllexport)
  #define exp __declspec(dllimport)

int exp ComInit (int Handle);

(tried in MC C++ 4.0 , should also work with Borland C)

There might appear problems, when you link a DLL thats links another DLL, the DLL might be loaded twice.Gregor


Author Comment

ID: 1336435
Edited text of question

Author Comment

ID: 1336436
Edited text of question

Author Comment

ID: 1336437
I am sorry, but the problem was in the C DLL :
It seems thet there must be two functions (except my regular code) : the WEP exit function (in 16 bit DLL) and an EntryPoint function.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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