我在主程序中调用了名字为A的Dll,在运行A.Dll的窗体的时候调用了B.Dll中的一个窗体,但是关闭的时候没有释放。
procedure TQulity1_F.OpenDllForm(var LibHandle: THandle; const DllName,
Func: string);
var
OpenForm: TOpenForm;
MyPointer: TFarProc;
Loaded: Boolean;
DllPathName: string;
begin
DllPathName := '.\' + trim(DllName) + '.dll';
Loaded := True;
try
if LibHandle = 0 then
begin
LibHandle := LoadLibrary(Pchar(DllPathName));
if LibHandle = 0 then
// raise EDLLError.Create('不能下载Dll文件!')
Application.MessageBox('不能下载Dll文件!', strCaption, MB_OK or
MB_IConERROR)
else
begin
MyPointer := GetProcAddress(LibHandle, Pchar(Func));
if MyPointer = nil then
begin
Loaded := False;
// RaiseLastWin32Error;
Application.MessageBox('Dll函数没找到!', strCaption, MB_OK +
MB_IConERROR);
end
else
begin
try
OpenForm := TOpenForm(MyPointer);
OpenForm(0,Self, Connect,Connect2, Parameters);
except
Loaded := False;
Application.MessageBox('系统出错!', strCaption, MB_OK or
MB_IConERROR);
end;
end;
end;
end
else
begin
Application.MessageBox('该程序已经运行!', strCaption, MB_OK or
MB_ICONINFORMATION);
end;
finally
if Loaded = False then
begin
FreeLibrary(LibHandle);
LibHandle := 0;
end;
end;
end;关闭再打开的时候提示‘系统出错!’
procedure TQulity1_F.OpenDllForm(var LibHandle: THandle; const DllName,
Func: string);
var
OpenForm: TOpenForm;
MyPointer: TFarProc;
Loaded: Boolean;
DllPathName: string;
begin
DllPathName := '.\' + trim(DllName) + '.dll';
Loaded := True;
try
if LibHandle = 0 then
begin
LibHandle := LoadLibrary(Pchar(DllPathName));
if LibHandle = 0 then
// raise EDLLError.Create('不能下载Dll文件!')
Application.MessageBox('不能下载Dll文件!', strCaption, MB_OK or
MB_IConERROR)
else
begin
MyPointer := GetProcAddress(LibHandle, Pchar(Func));
if MyPointer = nil then
begin
Loaded := False;
// RaiseLastWin32Error;
Application.MessageBox('Dll函数没找到!', strCaption, MB_OK +
MB_IConERROR);
end
else
begin
try
OpenForm := TOpenForm(MyPointer);
OpenForm(0,Self, Connect,Connect2, Parameters);
except
Loaded := False;
Application.MessageBox('系统出错!', strCaption, MB_OK or
MB_IConERROR);
end;
end;
end;
end
else
begin
Application.MessageBox('该程序已经运行!', strCaption, MB_OK or
MB_ICONINFORMATION);
end;
finally
if Loaded = False then
begin
FreeLibrary(LibHandle);
LibHandle := 0;
end;
end;
end;关闭再打开的时候提示‘系统出错!’
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货