Link to home
Start Free TrialLog in
Avatar of asi
asi

asked on

connection to dll

Hello,

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


thank you
Asi
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

   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.
Avatar of Melih SARICA
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

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

   FreeLibrary(DLLHandle);

   and relese some memory