Solved

connection to dll

Posted on 2004-04-25
4
137 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
[X]
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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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