نقل قول نوشته شده توسط Wish Master مشاهده تاپیک
استفاده از DLLها در دلفی
استفاده از یک DLL بصورت دینامیکی
برای استفاده از یک DLL ‌بصورت دینامیکی، ابتدا نام توابعی را که در فایل DLL شما موجود است بصورت زیر تعریف نمایید:




unit UMain;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TShowdemoFormModal= Function :integer;
.
.
.







دقت کنید که نام برنامه انتخابی پیش فرض Main و با نام UMain.pas ذخیره گشته است. حال برای لود کردن DLL یادشده، یک دکمه بر روی فرم قرارداده آنرا بصورت زیر کد نویسی کنید:




var
hndDLLHandle:THandle;
ShowdemoFormModal:TShowdemoFormModal;

procedure TFMain.Button1Click(Sender: TObject);
begin
try
hndDLLHandle:=LoadLibrary('Demodll.dll');

if hndDLLHandle <> 0 then begin
@ShowdemoFormModal:=getProcAddress(hndDLLHandle,'S howdemoFormModal');

if addr(ShowdemoFormModal) <> nil then begin
ShowdemoFormModal;
end
else
showmessage ('function not exists ...');
end
else
showMessage('Dll Not Found!');
finally
freelibrary(hndDLLHandle);
end;
end;
سلام
یک سئوال: اگر تعداد توابع موجود در dll (که خودم بنویسم)خیلی باشد. یعنی حدود 10 -15 تا باشد؛ باید همه را یکی یکی تعریف کنیم؟
راهی نیست که بتوان توابع موجود در dll رو بدون اینکه یکی یکی تعریفشون کنیم, استفاده کنیم؟