在那个进程退出时, SendMessage to all windows 然后你的 WndProc 程序处理那个消息。这种办法比较可行。但是要求,那个退出的进程是你编写的。
procedure Tfmain.execFile(const Filename:string); var hprocess:TProcessInformation; si: TStartupInfo; dwExit:DWORD; begin if not FileExists(Filename) then begin showmessage('Cannot Open '+ Filename + ' Please contact the saler!'); exit; end; si.cb:=sizeof(si); GetStartupInfo(si); if CreateProcess(nil,pchar(Filename),nil,nil,false,0,nil,nil,si,hprocess) then begin closehandle(hprocess.hThread); WaitforSingleObject(hprocess.hProcess,INFINITE); getexitcodeprocess(hprocess.hProcess,dwExit); closeHandle(hprocess.hProcess); end; end; 这样能挂起主进程,等待调用的进程结束!!!! 参考下吧
在那个进程退出时, SendMessage to all windows 然后你的 WndProc 程序处理那个消息。这种办法比较可行。但是要求,那个退出的进程是你编写的。
var
hprocess:TProcessInformation;
si: TStartupInfo;
dwExit:DWORD;
begin
if not FileExists(Filename) then
begin
showmessage('Cannot Open '+ Filename + ' Please contact the saler!');
exit;
end;
si.cb:=sizeof(si);
GetStartupInfo(si);
if CreateProcess(nil,pchar(Filename),nil,nil,false,0,nil,nil,si,hprocess) then
begin
closehandle(hprocess.hThread);
WaitforSingleObject(hprocess.hProcess,INFINITE);
getexitcodeprocess(hprocess.hProcess,dwExit);
closeHandle(hprocess.hProcess);
end;
end;
这样能挂起主进程,等待调用的进程结束!!!!
参考下吧