here is a function that you want to get<br>function WinExecAndWait32(FileName: string; Visibility: integer): Dword;<br> {执行一个外部程序并等待其结束}<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 } NORMAL_PRIORITY_CLASS,<br> nil, { pointer to new environment block }<br> nil, { pointer to current directory name }<br> StartupInfo, { pointer to STARTUPINFO }<br> ProcessInfo)<br> then Result := 1 { pointer to PROCESS_INF }<br> else begin<br> while WaitforSingleObject(ProcessInfo.hProcess, 10) = WAIT_TIMEOUT<br> do Application.ProcessMessages;<br> GetExitCodeProcess(ProcessInfo.hProcess, Result);<br> end;<br>end;