The hanging will be due to this: WaitForSingleObject(procInfo.hProcess, Infinite);
If you want Windows to handle messages while the process is busy, you would need to use something like this. repeat WaitForSingleObject(procInfo.hProcess, 100); Application.ProcessMessages; GetExitCodeProcess(procInfo.hProcess, return); until return = 0 Ross. ----- Original Message ----- From: "delphi _sloHOST_" <[EMAIL PROTECTED]> To: "'Borland's Delphi Discussion List'" <[email protected]> Sent: Saturday, January 07, 2006 3:37 AM Subject: Frozen application Hi. I have application for compressing diffrent folders on my network (I use external program 7-zip: 7z.exe) and the problem is whenever I execute 7-zip with function: {This function runs a program (console or batch) and adds its output to Memo1} function TfArhiva.RunProgAndCaptureOutput(const _dirName, _exeName, _cmdLine: string;povratni_info:TStrings): Boolean; var start: TStartupInfo; procInfo: TProcessInformation; tmpName: string; tmp: Windows.THandle; tmpSec: TSecurityAttributes; res: TStringList; return: Cardinal; begin povratni_info.Clear; Result := False; try { Setze ein Temporäres File } { Set a temporary file } tmpName := 'Test.tmp'; FillChar(tmpSec, SizeOf(tmpSec), #0); tmpSec.nLength := SizeOf(tmpSec); tmpSec.bInheritHandle := True; tmp := Windows.CreateFile(PChar(tmpName), Generic_Write, File_Share_Write, @tmpSec, Create_Always, File_Attribute_Normal, 0); try FillChar(start, SizeOf(start), #0); start.cb := SizeOf(start); start.hStdOutput := tmp; start.dwFlags := StartF_UseStdHandles or StartF_UseShowWindow; //start.wShowWindow := SW_Minimize; Start.wShowWindow := SW_HIDE; { Starte das Programm } { Start the program } if CreateProcess(nil, PChar(_exeName + ' ' + _cmdLine), nil, nil, True, 0, nil, PChar(_dirName), start, procInfo) then begin SetPriorityClass(procInfo.hProcess, Idle_Priority_Class); WaitForSingleObject(procInfo.hProcess, Infinite); GetExitCodeProcess(procInfo.hProcess, return); Result := (return = 0); CloseHandle(procInfo.hThread); CloseHandle(procInfo.hProcess); Windows.CloseHandle(tmp); { Die Ausgaben hinzufügen } { Add the output } res := TStringList.Create; try res.LoadFromFile(tmpName); povratni_info.AddStrings(res); finally res.Free; end; Windows.DeleteFile(PChar(tmpName)); end else begin Application.MessageBox(PChar(SysErrorMessage(GetLastError())), 'RunCaptured Error', MB_OK); end; except Windows.CloseHandle(tmp); Windows.DeleteFile(PChar(tmpName)); raise; end; finally end; end; The application >freezes< until 7-zip is done. How could I prevent this >freezing<?????? Thanx all. Aris. _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

