DELPHI封裝dll的例子,留作紀念

2021-05-25 01:33:13 字數 1207 閱讀 4059

主程式

unit unit1;

inte***ce

uses

windows, messages, sysutils, variants, classes, graphics, controls, forms,

dialogs, stdctrls;

type

tform1 = class(tform)

btn1: tbutton;

procedure btn1click(sender: tobject);

private

public

end;

function   returncall(p:pchar):boolean;stdcall;external   'test.dll ';

varform1: tform1;

implementation

procedure tform1.btn1click(sender: tobject);

varp:pchar;

begin

tryp:=stralloc(1024);

if   returncall(p)   then

showmessage(string(p));

finally

strdispose(p);

end;

end;

end.

dll檔案

library test;

uses

sysutils,

classes,

forms,

windows,

messages,

unit2 in 'unit2.pas' ;

varfrmtest:tfrmtest;

num:string;

function   returncall(p:pchar):boolean;stdcall;

begin

with   tfrmtest.create(nil)   do

tryshowmodal;

num:=edt1.text;

strcopy(p,pchar(num));

result:=true;

finally

free;

end;

end;

exports

returncall;

begin

end.

delphi中dll運用的例子

dll工程檔案testdll.pas library testdll uses sysutils,classes,dllfrm in dllfrm.pas 輸出showdllmodalform,showdllform,showcalendar介面方法,以便外部程式呼叫 exports showdll...

在dll中delphi中封裝窗體

dll工程library formdll uses sysutils,classes,forms,dllform in dllform.pas dllfrom2 in dllfrom2.pas begin end.dll單元檔案一 unit dllform inte ce uses windows,...

在dll中delphi中封裝窗體 例項

dll工程 library formdll uses sysutils,classes,forms,dllform in dllform.pas dllfrom2 in dllfrom2.pas begin end.dll單元檔案一 unit dllform inte ce uses windows...