Solved

connection to dll

Posted on 2004-04-25
4
135 Views
Last Modified: 2010-04-05
Hello,

Is ther an easy way to connect delphi application with DLL (not ocx/activeX) ?


thank you
Asi
0
Comment
Question by:asi
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 35 total points
ID: 10911814

Suppose You have library Export.Dll with procedure _WriteTXT.
Put the line below to Your interface section and You can use it.

procedure _WriteTXT(fname,tekst: PChar);cdecl; external 'Export.Dll';

Of course cdecl use when appropriate.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10912202

   another possibility :

   procedure YourProcedureName (Param1, Param2 : Integer); {$IFDEF WIN32} stdcall;{$ENDIF}
   ...
   var DLLHandle : Integer;
   ...
      DLLHandle := LoadLibrary(YourDLLlibrary.dll);
      @YourProcedureName := GetProcAddress(DLLHandle, 'ProcedureInDLL');

   and then you execute YourProcedureName as usual.
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10915702
Here is a small dll sample:

library MyLibrary;

uses ........ ;
exports
   myProcedure;

Procedure myProcedure(mEdit:Tedit);safecall;
begin
   mEdit.text:='Hello From DLL';
end;

end;

And the way to Call it from  ur Delphi application
 there r 2 ways.. as Ivanov and mokule says...

in the way mokule said..

  dll is loaded when ur application is start running .. loaded in to the memory.. And ur procedure ll be loaded too

but in the way Ivanov told;
  UR dll ll be loaded with the procedure loadlibrary and ur procedure ll be loaded with GetProcAddress..

The way ivanov told is the best in my opinion.. Why ?  Only ur application ll be loaded in to the memory.. it means , if u use lots of dll's u wont  waste memory with loading unused procedures.  U ll load the Dll's when ever u want..  U ll have a control over all Dll's and procs. Loading and unloading..

 
 
 

 
i
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10915858

   I think so, because when you finish executing the function you can cal

   FreeLibrary(DLLHandle);

   and relese some memory
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Communication Between RC4 Delphi <-> PHP 3 115
HTML text in the body of an email (delphi code) 12 120
RESTRequest Parameter 4 31
Wincontrol not (correctly) drawn 15 38
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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