AddC index 1 name 'ADDC' resident,
SubC index 2,
MulC index 3,
DivC index 4;
begin
end.
Bu yerda stdcall bu DLL ga Delphi dan boshqa tillardan murojaat qilishga imkon beradi. Agar bibliotekaga fakat Delphi tilidagi dasturdan murojaat qilinsa bu so’zning keragi yo’q.
Podprogrammalarga murojaat qilish uchun ularni kuyidagicha e’lon qilish lozim:
Procedure MyProc; External 'MyDLL';
Agar indeks bo’yicha chaqirish lozim bulsa:
Procedure MyProc; External 'MyDLL' index 2;
Bundan tashqari dasturchi tashqi nomni o’zgartirishi xam mumkin:
Procedure MyProc; External 'MyDLL' Name 'ExtName';
Foydalanish
Statik yuklash
Dasturda Smpix bibliotekasi quyidagicha e’lon qilinishi lozim.
type
TComplex = record Re, Im: Real;
end;
function ADDC(x, y: TComplex): TComplex; stdcall; External 'Cmplx' ;
function SubC(x, y: TComplex): TComplex; stdcall; External 'Cmplx' ;
function MulC(x, y: TComplex): TComplex; stdcall; External 'Cmplx' ;
function DivC(x, y: TComplex): TComplex; stdcall; External 'Cmplx';
Interfeysli modul
DLL-podprogrammalarni chaqirishda yozuv kabi murakkab turdagi ma’lumotlarni uzatishga to’g’ri kelishi mumkin. Agar biror DLL ga kup murojaat qilinsa murakkab tur e’lon kilingan interfeysli moduldan foydalanish qulaydir. Masalan:
Unit Complx;
Interface
type
TComplex = record Re, Im: Real;
end;
function AddC(x, y: TComplex): TComplex; stdcall;
External 'Cmplx' index 1;
function SubC(x, y: TComplex): TComplex; stdcall;
External 'Cmplx' index 2;
function MulC(x, y: TComplex): TComplex; stdcall;
External 'Cmplx' index 3;
function DivC(x, y: TComplex): TComplex; stdcall;
External 'Cmplx' index 4;
Implementation end.
Boshqa tilda yozilgan DLL protseduralariga murojaat qilinganda ularning tashqi nomi Delphi qoidasiga to’g’ri kelmasligi mumkin. Masalan C++ tili identifikatorlarda “@” simvolidan foydalanishga ruxsat beradi. Bu xolda Delphi qoidasiga mos nom berib name suzidan sung asl nomini ko’rsatish kerak. Masalan:
|