Y
ywws
Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下函数在DELPHI中调用一DOS程序并等待它结束,可是当此程序<br>运行完毕后却一定让我关闭DOS窗口,才执行下一语句,我想不显示此<br>窗口,却DEADLOCK了。该如何让它执行完后自动执行下一语句呢,当然<br>若没执行完,超过TIMEOUT后也自动执行下一语句。<br>function WinExecAndWait32(FileName:String; Visibility : integer):integer; <br>var <br> zAppName:array[0..512] of char; <br> zCurDir:array[0..255] of char; <br> WorkDir:String; <br> StartupInfo:TStartupInfo; <br> ProcessInfo:TProcessInformation; <br>begin <br> StrPCopy(zAppName,FileName); <br> GetDir(0,WorkDir); <br> StrPCopy(zCurDir,WorkDir); <br> FillChar(StartupInfo,Sizeof(StartupInfo),#0); <br> StartupInfo.cb := Sizeof(StartupInfo); <br> StartupInfo.dwFlags := STARTF_USESHOWWINDOW; <br> StartupInfo.wShowWindow := Visibility; <br> if not CreateProcess(nil, <br> zAppName, { pointer to command line string } <br> nil, { pointer to process security attributes } <br> nil, { pointer to thread security attributes } <br> false, { handle inheritance flag } <br> CREATE_NEW_CONSOLE or { creation flags } <br> NORMAL_PRIORITY_CLASS, <br> nil, { pointer to new environment block } <br> nil, { pointer to current directory name } <br> StartupInfo, { pointer to STARTUPINFO } <br> ProcessInfo) then Result := -1 { pointer to PROCESS_INF } <br> else begin <br> WaitforSingleObject(ProcessInfo.hProcess,INFINITE); <br> GetExitCodeProcess(ProcessInfo.hProcess,Result); <br> end; <br>end;