delphi 中DLL的建立

本文详细介绍了DLL的创建过程及如何在项目中调用DLL,包括使用Visual Studio的向导创建DLL,定义函数和导出函数等步骤,并通过实例展示了DLL的调用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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. 




附件列表

 

转载于:https://www.cnblogs.com/xe2011/p/3876090.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值