会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Testudo
每天要进步一点点。
博客园
首页
新随笔
联系
订阅
管理
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)
附件列表
posted @
2014-07-29 17:45
XE2011
阅读(
547
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告