//通過 dll wizard 建立:librarytestdll;
uses
sysutils,
classes,
dialogs;
//建立過程
proceduretest;
begin
showmessage('testdll.test'
);end;//輸出
exports
test;
begin
end.
//在其他工程呼叫,如果不在乙個工程組,需要在相同目錄下、system32下或指定路徑;
//宣告可以在實現區或介面區,這裡的函式名要一致,甚至大小寫。
//呼叫測試:
proceduretest;external
'testdll.dll'
;proceduretform1.
button1click(sender: tobject);
begin
test;
end;
呼叫外部dll
unitunit1;inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tform1 =class(tform)
button1: tbutton;
procedurebutton1click(sender: tobject);
private
public
end;
var
form1: tform1;
//mb 函式的宣告:
functionmb(hwnd: hwnd; lptext, lpcaption: pchar; utype: uint): integer;stdcall;
implementation
//function mb(hwnd: hwnd; lptext, lpcaption: pchar; utype: uint): integer;
// stdcall; external user32 name 'messageboxa';
//function mb(hwnd: hwnd; lptext, lpcaption: pchar; utype: uint): integer;
// stdcall; external 'user32.dll' name 'messageboxa';
//function mb(hwnd: longword; lptext, lpcaption: pchar; utype: longword): integer;
// stdcall; external 'user32.dll' name 'messageboxa';
//function mb(hwnd: cardinal; lptext, lpcaption: pchar; utype: cardinal): integer;
// stdcall; external 'user32.dll' name 'messageboxa';
//function mb(hwnd: cardinal; lptext, lpcaption: pchar; utype: cardinal): integer;
// stdcall;
functionmb;external
'user32.dll'
name 'messageboxa'
;//呼叫測試:
proceduretform1.
button1click(sender: tobject);
var
t,b: pchar;
begin
t := '標題'
; b := '內容'
; mb(0
,b,t,0
);end;
end.
DELPHI中建立呼叫DLL
一,新建 new other dll wizard 二,library new uses sysutils,classes,dialogs procedure dll begin showmessage delphi end exports dll begin end.三,儲存,四,project ...
建立並呼叫 DLL 1
通過 dll wizard 建立 librarytestdll uses sysutils,classes,dialogs 建立過程 proceduretest begin showmessage testdll.test end 輸出 exports test begin end.在其他工程呼叫,...
delphi 建立DLL檔案 及其呼叫和注意事項
首先建立乙個dll檔案,專案自帶的 為 library projectpnr uses sysutils,classes,再在uses下宣告乙個函式 function add a,b integer integer 函式功能 實現a,b相加 begin result a b endexports a...