Mega Code Archive

 
Categories / Delphi / Files
 

Dll yazma ve kullanma

library topla_dll; uses SysUtils, Classes; {$R *.res} function carp(x,y:integer):integer;export; begin carp:=x*y; end; function topla(x,y:integer):integer;export; begin topla:=x+y; end; exports topla,carp; begin end. bu kodların ardından kaydedin ve adını "topla_dll" verin ve ardından CTRL+F9 yaparak derleyin kaydettiğiniz klasöre bakarsanız DLL dosyasının oluşmuş olduğunu göreceksiniz. /////Proje------------------------------------------------ iki tane buton ekleyin ve kodları aşağıya göre uyarlayın. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation Function topla(x,y:integer):integer;far;external 'topla_dll.dll'; Function carp(x,y:integer):integer;far;external 'topla_dll.dll'; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Showmessage('10+5 ='+inttostr(topla(10,5))); end; procedure TForm1.Button2Click(Sender: TObject); begin Showmessage('8*5 ='+inttostr(carp(8,5))); end; end.