我写了一个dll,封装了几个窗口,窗口之间有调度操作,
应用部分:procedure TForm1.Button1Click(Sender: TObject);
type
TFunc=procedure;stdcall;
var
Th:Thandle;
Tf:TFunc;
begin
Th:=LoadLibrary('ReStore.dll'); {装载DLL}
if Th>0
then begin
try
@Tf:=GetProcAddress(Th,PChar('createform'));
if @Tf<>nil
then tf
else ShowMessage('createform函数没有找到');
finally
FreeLibrary(Th);
end;
end
else ShowMessage('ReStore.dll没有找到');
end;
DLL定义:uses
SysUtils,
Classes,
AdminRestoreDBSelectDB in 'AdminRestoreDBSelectDB.pas' {AdminRestoreDBSelectDBForm},
AdminDeleteDB in 'AdminDeleteDB.pas' {AdminDeleteDBForm},
AdminRestoreDB in 'AdminRestoreDB.pas' {AdminRestoreDBForm};
procedure createform;stdcall;
begin
AdminRestoreDBForm:=TAdminRestoreDBForm.Create(nil);
AdminRestoreDBForm.ShowModal;
end;{$R *.res}
exports createform;
begin
end.
因为调用dll后马上释放了dll,所以关闭dll的打开窗口后会抛出错误,但如果不在try...finally里释放dll,又该怎么执行FreeLibrary()呢?
应用部分:procedure TForm1.Button1Click(Sender: TObject);
type
TFunc=procedure;stdcall;
var
Th:Thandle;
Tf:TFunc;
begin
Th:=LoadLibrary('ReStore.dll'); {装载DLL}
if Th>0
then begin
try
@Tf:=GetProcAddress(Th,PChar('createform'));
if @Tf<>nil
then tf
else ShowMessage('createform函数没有找到');
finally
FreeLibrary(Th);
end;
end
else ShowMessage('ReStore.dll没有找到');
end;
DLL定义:uses
SysUtils,
Classes,
AdminRestoreDBSelectDB in 'AdminRestoreDBSelectDB.pas' {AdminRestoreDBSelectDBForm},
AdminDeleteDB in 'AdminDeleteDB.pas' {AdminDeleteDBForm},
AdminRestoreDB in 'AdminRestoreDB.pas' {AdminRestoreDBForm};
procedure createform;stdcall;
begin
AdminRestoreDBForm:=TAdminRestoreDBForm.Create(nil);
AdminRestoreDBForm.ShowModal;
end;{$R *.res}
exports createform;
begin
end.
因为调用dll后马上释放了dll,所以关闭dll的打开窗口后会抛出错误,但如果不在try...finally里释放dll,又该怎么执行FreeLibrary()呢?
解决方案 »
- ImageEn中怎么把各层的内容合并到一起,然后保存
- 奇怪的问题。看看有没有人能解决?关于多线程。
- 200元请高手指导套票打印!限南京!!
- 怎样完全御载BDE
- treeview的问题,高手进来看看!
- 我现在修改桌面图标的显示间距问题,为什么设为 宽:25,注册表的IconSpacing值为:-855,或宽为:30,IconSpacing值为:-930,它的计算公
- 关于SQLConnection的连接问题?
- 在Delphi中读取Oracle中Blob字段的问题,大家帮忙看一下.~~
- 请MIS高手指教一下,怎么入门???(大家都来讨论一下!谢了!)
- 工程中加了TFcOutLookBar控件后,提示Class TFcShapeBtn 找不到.
- 求一个在线自动升级的程序代码
- TChart控件用Canvas画股票K线的几个问题(见图)
fastmm4没用过,能略解一下作用吗?