delphi dll 实例 与 dll窗体实例

本文介绍了一个使用 Delphi 编写的动态链接库(DLL)示例,其中包括 Min 和 Max 函数用于比较两个整数的大小,以及 showmyform 过程展示一个窗体。该 DLL 示例还提供了 SynAPP 和 ShowForm 接口,允许外部应用程序创建并显示窗体。

delphi dll 实例 与 dll窗体实例

本动态链接库方法有

Min,Max,SynAPP,ShowForm,showmyform

dll工程文件

Library Project1;
uses
dllUnit1 in 'dllUnit1.pas' {Form1};

function Min(X, Y: Integer): Integer; export;
begin
if X < Y then Min := X else Min := Y;
end;
function Max(X, Y: Integer): Integer; export;
begin
if X > Y then Max := X else Max := Y;

end;
procedure showmyform();export;
begin
Form1 := TForm1.Create(nil);
Form1.ShowModal;
end;

exports
Min,Max,SynAPP,ShowForm,showmyform;

begin

end.

窗体单元文件:

unit dllUnit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

procedure SynAPP(App:THandle);stdcall;
procedure ShowForm;stdcall;
implementation



{$R *.dfm}

procedure SynAPP(App:THandle );stdcall;
begin
Application.Handle := App;
end;
procedure ShowForm;stdcall;
begin

Form1 := TForm1.Create (Application);


// Form2 := TForm2.Create(Application);
Form1.ShowModal;

end;


procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;

end.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值