[blue]http://www.delphibbs.com/delphibbs/dispq.asp?lid=311324[/blue]<br><br>procedure TfrmMain.WaitOnProgram(Const sCommandLine:string;<br> Const waitdead:Boolean;var iExit:Cardinal);<br>var<br> bCreateProcess: LongBool;<br> lpStartupInfo: _STARTUPINFOA;<br> lpProcessInformation: _PROCESS_INFORMATION;<br>begin<br> lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br> lpStartupInfo.wShowWindow := SW_MINIMIZE;<br> bCreateProcess:=CreateProcess(nil,PChar(sCommandLine),<br> nil,nil,False,<br> NORMAL_PRIORITY_CLASS,nil,nil,<br> lpStartupInfo,lpProcessInformation);<br> if bCreateProcess then<br> begin<br> if waitdead then<br> begin<br> WaitForSingleObject(lpProcessInformation.hProcess,INFINITE);<br> //GetExitCodeProcess(lpProcessInformation.hProcess,iExit);<br> end<br> else<br> begin<br> GetExitCodeProcess(lpProcessInformation.hProcess,iExit);<br> While iExit = STILL_ACTIVE do<br> begin<br> frmMain.insertprocressbar;<br> Application.ProcessMessages;<br> GetExitCodeProcess(lpProcessInformation.hProcess,iExit);<br> end;<br> end;<br> end<br> else<br> begin<br> iExit:=9999;<br> ShowMessage('创建进程失败!'+#10+#10+sCommandLine+'执行错误.');<br> end;<br>end;