Dll释放问题
主窗体:
unit Main
interface
type
TBaseDllShowChild = procedure(ParentApplication: TApplication;ParentForm: TForm;FormName: string; FHanlde: Hwnd); stdcall;
EDllLoadError = class(Exception);
TFrmMain = class(TfrmComMain)
---------------------
---------------------
procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
procedure BaseDllShowForm(Sender: TObject;FormName: string; DllName:String);
end;
procedure TFrmMain.BaseDllShowForm(Sender: TObject; FormName,
DllName: String);
var
BaseDllShowChild: TBaseDllShowChild;
begin
BeginShow(Sender);
if BaseDllHandle = 0 then
BaseDllHandle := LoadLibrary(PChar(DllName+'.Dll'));
if BaseDllHandle = 0 then
Raise EDllLoadError.Create('装载动态链接库'+DllName+'.Dll'+'失败!');
@BaseDllShowChild := GetProcAddress(BaseDllHandle,'BaseDllShowChild');
if @BaseDllShowChild <> nil then
BaseDllShowChild(Application,Self,FormName,Application.Handle)
else
RaiseLastWin32Error;
EndShow(Sender);
end;
procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
if BaseDllHandle <> 0 then
begin
FreeLibrary(BaseDllHandle);
BaseDllHandle := 0;
end;
Action :=caFree;
end;
Dll:
procedure BaseDllShowChild(ParentApplication: TApplication; ParentForm: TForm;FormName:String;FHandle:Hwnd); export; stdcall;
begin
Application.Handle := FHandle;
Application:=ParentApplication;
FormName := UpperCase(FormName);
if FormName='FRMHRRANK' then
begin
if not Assigned(frmHrRank) then
frmHrRank := TfrmHrRank.Create(ParentForm);
frmHrRank.Show;
end;
end;
procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then
Data.Free;
end;
exports
BaseDllShowChild;
begin
DllName := 'BaseDll';
if not Assigned(Data) then
Data := TData.Create(Application);
DLLProc := @DLLUnloadProc;
end.
----------------------------------------------------------------------------------------
程序采用MDI窗体,能够正常调用DLL中的窗体,但关闭主程序后DLL不能正常释放,还在任务管理器占用11M的内存;请帮忙解决!
unit Main
interface
type
TBaseDllShowChild = procedure(ParentApplication: TApplication;ParentForm: TForm;FormName: string; FHanlde: Hwnd); stdcall;
EDllLoadError = class(Exception);
TFrmMain = class(TfrmComMain)
---------------------
---------------------
procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
procedure BaseDllShowForm(Sender: TObject;FormName: string; DllName:String);
end;
procedure TFrmMain.BaseDllShowForm(Sender: TObject; FormName,
DllName: String);
var
BaseDllShowChild: TBaseDllShowChild;
begin
BeginShow(Sender);
if BaseDllHandle = 0 then
BaseDllHandle := LoadLibrary(PChar(DllName+'.Dll'));
if BaseDllHandle = 0 then
Raise EDllLoadError.Create('装载动态链接库'+DllName+'.Dll'+'失败!');
@BaseDllShowChild := GetProcAddress(BaseDllHandle,'BaseDllShowChild');
if @BaseDllShowChild <> nil then
BaseDllShowChild(Application,Self,FormName,Application.Handle)
else
RaiseLastWin32Error;
EndShow(Sender);
end;
procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
if BaseDllHandle <> 0 then
begin
FreeLibrary(BaseDllHandle);
BaseDllHandle := 0;
end;
Action :=caFree;
end;
Dll:
procedure BaseDllShowChild(ParentApplication: TApplication; ParentForm: TForm;FormName:String;FHandle:Hwnd); export; stdcall;
begin
Application.Handle := FHandle;
Application:=ParentApplication;
FormName := UpperCase(FormName);
if FormName='FRMHRRANK' then
begin
if not Assigned(frmHrRank) then
frmHrRank := TfrmHrRank.Create(ParentForm);
frmHrRank.Show;
end;
end;
procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then
Data.Free;
end;
exports
BaseDllShowChild;
begin
DllName := 'BaseDll';
if not Assigned(Data) then
Data := TData.Create(Application);
DLLProc := @DLLUnloadProc;
end.
----------------------------------------------------------------------------------------
程序采用MDI窗体,能够正常调用DLL中的窗体,但关闭主程序后DLL不能正常释放,还在任务管理器占用11M的内存;请帮忙解决!
...全文
相关推荐
DLL占用查看器
查看EXE占用DLL情况,强力清除无法删除的DLL文件.很好用的小工具
聚类实战资源清单:从数据预处理到业务可解释的完整路径
聚类是无监督学习的核心技术,其本质是基于距离或相似度对样本进行结构化分组。理解其数学原理(如质心迭代、密度连通性、谱图划分)是基础,但真正决定落地效果的是工程实践能力——包括高维稀疏数据标准化策略、噪声与缺失值协同处理、算法适用边界的量化判断,以及结果向业务语言的可信转化。本文聚焦真实场景中高频痛点:DBSCAN参数调优失准、K-means因量纲失衡失效、谱聚类内存爆炸、聚类结果无法向非技术方解释等。围绕Clustering和Curated两大核心热词,提供经生产验证的可执行资源、决策树与避坑指南,覆盖电商
FreeMem释放内存的DLL,效果明显
释放内存的DLL,无入口参数,效果明显,,,,,,,,,,,,,。
delphi 调用DLL 及释放例子
delphi 调用DLL 及释放例子 一个主程序调用DLL 并在主程式中释放DLL的例子
delphi 调用DLL 及释放例子.rar
delphi 调用DLL 及释放例子.rar


数据库相关
