Z
zitai
Unregistered / Unconfirmed
GUEST, unregistred user!
dll中:
var
oldapplication:THandle
procedure ModMain(ParentWnd: HWND); stdcall;
begin
oldapplication:=application.handle;
Application.handle := ParentWnd; //传递句柄
FormMain:=TFormMain.Create(application);
With FormMain do
begin
try
Show;
except
Free;
end;
end;
end;
主form中:
loadlibrary正常,就是释放时出错。调试时最后出现cpu信息框是地址出错。
释放代码如下:
procedure TFrame.freemodel(modhandle:THandle);
begin
freelibrary(Thandle);
end;
一运行这个函数freemodel后,主程序就自动释放了。?????
后来在dll中加了段代码是:
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Application.MessageBox('退出?','退出信息',MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON1)=IDYES then
begin
Action:=caFree;
application:=oldapplication
end
else
Action:=caNone;
end;
同样不可以的。???
var
oldapplication:THandle
procedure ModMain(ParentWnd: HWND); stdcall;
begin
oldapplication:=application.handle;
Application.handle := ParentWnd; //传递句柄
FormMain:=TFormMain.Create(application);
With FormMain do
begin
try
Show;
except
Free;
end;
end;
end;
主form中:
loadlibrary正常,就是释放时出错。调试时最后出现cpu信息框是地址出错。
释放代码如下:
procedure TFrame.freemodel(modhandle:THandle);
begin
freelibrary(Thandle);
end;
一运行这个函数freemodel后,主程序就自动释放了。?????
后来在dll中加了段代码是:
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Application.MessageBox('退出?','退出信息',MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON1)=IDYES then
begin
Action:=caFree;
application:=oldapplication
end
else
Action:=caNone;
end;
同样不可以的。???