Delphi 2010 ve Delpi XE2 aynı pc üzerinde kullanımı!
Destek talebi(Lütfen oy verelim!)
Sitemiz üye alımına kapatılmıştır!
! CODEBANK 2012 !
İNDİRMEK&DETAYLI BİLGİ ALMAK İÇİN BURAYI TIKLAYINIZ.
0 Üye ve 1 Ziyaretçi konuyu incelemekte.
library deneme;usesDialogs,Windows;procedure MesajGoster;beginMessageDlg('ORNEK DLL UYGULAMASI ',mtConfirmation,[mbok],0);end;// exports ifadesi olusturulan procedure nin // baska programlardan cagirilabilmesi icinexportsMesajGoster;beginend.
. . privatepublicend; procedure MesajGoster; external 'Deneme.dll';var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);beginMesajGoster;end;end.
unit UFormDll;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) private public end; Procedure ShowFormDll ;var Form1: TForm1;implementation{$R *.DFM}Procedure ShowFormDll ; // Kullanımı zorunludur. Dll içinden bu Procedureyi Çağırmalısınız.//Kod Formun Oluşturulmasını SağlarBegin Form1:= TForm1.Create(application); Form1.Showmodal ; Form1.Free; Form1 := nil ;end ;end.
library FormDll;uses SysUtils, Classes, UFormDll in 'UFormDll.pas' {Form1};exports ShowFormDll ;{$R *.RES}beginend.
Exports:Exports ifadesi sizin yazdiginiz Dll deki procedure veya fonsiyonlaridiger programlardan cagirabilmeniz icin ; daha dogrusu ihrac edebilmeniz icin yardimci olur. yazdiginiz Dll' inExprots bloguna alinmamis Procedure veya parametre unitleridiger programlardan cagirilamaz.örneginExports ifadesini asagidaki gibi degistirebilirizExports ShowFormDll name 'ShowForm' ;
function MessageBox(HWnd: Integer; Text, Caption: PChar; Flags: Integer): Integer; stdcall; external 'user32.dll' name 'MessageBox';
{$LINK} {$L *.OBJ}Procedure DenemeMesaj;External; ifadesini kullanarak acabiliriz.
procedure DisplaySum(A,B:integer);stdcall;begin MessageBox(Handle,PChar('A + B = ' + IntToStr(A+B)),'Dinamik DLL',MB_OK);end;exports DisplaySum;
type TSumFunction=procedure (A,B:integer);stdcall;
procedure Hesapla(A,B:integer);var DLLHandle:THandle; AFunction:TSumFunction;begin //DLL dosyasını belleğe alalım DLLHandle:=LoadLibrary('DLL_Path_AND_NAME'); //Fonksiyonun adresini alalım AFunction:=GetProcAddress(DLLHandle,'DisplaySum'); //Fonksiyonu çalıştıralım AFunction(A,B); //Fonksiyonu bellekten silelim FreeLibrary(DLLHandle);end;