Solved

connection to dll

Posted on 2004-04-25
4
133 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

18 Experts available now in Live!

Get 1:1 Help Now