delphi 中DLL的建立 Dll的创建与调用 File ->New->Other->Dll Wizard DLL的创建 //可以将本代码复制粘贴到项目中 library Project1; uses SysUtils, Classes, Windows, Forms; {$R *.res} function Min(x,y:Integer):Integer;stdcall; begin if (x<y) then Result:=x else Result:=y; end; procedure MsgBox(Msg:string;Title:string;uType:LongInt=MB_OK);stdcall; begin Application.MessageBox(PAnsiChar(Msg),PAnsiChar(Title),uType); end; exports Min, MsgBox; begin end. DLL的调用1 //将Project1.dll文件复制到本项目中 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; function Min(x,y:Integer):Integer;stdcall;external 'project1.dll'; procedure MsgBox(Msg:string;Title:string;uType:LongInt=MB_OK);stdcall;external 'project1.dll'; 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 {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(IntToStr(Min(3,2))); end; procedure TForm1.Button2Click(Sender: TObject); begin MsgBox('Hello','Tips',MB_OK+MB_ICONINFORMATION); end; end. 来自为知笔记(Wiz)附件列表