DLL definition
LibrarySUM;{Important Note about DLL memory Management:sharemem must is the first unit in your library ' s USES clause and your P Roject ' s (select Project-view Source) USES clause If your DLL exports any procedures or functions this pass strings as P Arameters or function results. This is dll--even in those and nested, applies to all strings passed to and from your records classes. SHAREMEM is the interface unit to the BORLNDMM. DLL shared Memory manager, which must is deployed along with your DLL. To avoid using BORLNDMM. DLL, pass string information using PChar or shortstring parameters. }usessysutils, Classes, Uni_dllfileinch 'Uni_dllfile.pas';{$R *.res} exportssum1;beginEnd.
Unit Uni_dllfile; Interface function sum1 (a,b:integer): Integer; stdcall ; implementation function sum1 (A,b:integer): Integer; begin Result:=a+b; End ; End.
Call
Unituni_sum;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;typeTForm1=class(tform) Edit2:tedit; Label1:tlabel; Button1:tbutton; Edit3:tedit; Edit1:tedit; procedureButton1Click (Sender:tobject); Private {Private Declarations} Public {Public Declarations} End;varForm1:tform1;Implementation functionSUM1 (A,b:integer): Integer;stdcall;External 'Dall_pak\sum.dll';{$R *.DFM}procedureTform1.button1click (sender:tobject);beginedit3. Text:=IntToStr (sum1 (Strtoint (edit1. Text), Strtoint (edit2. Text ));End;End.
Use of Delphi DLLs