AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

WaitForSingleObject und Child-Prozesse

Ein Thema von nru · begonnen am 9. Sep 2011 · letzter Beitrag vom 12. Sep 2011
Antwort Antwort
QuickAndDirty

Registriert seit: 13. Jan 2004
Ort: Hamm(Westf)
2.056 Beiträge
 
Delphi 12 Athens
 
#1

AW: WaitForSingleObject und Child-Prozesse

  Alt 9. Sep 2011, 23:38
Ich weiß nicht...laut MSDN funktioniert WaitForSingleObject nicht wenn weitere fenster aus dem prozess
heraus entstehen...

Sprich ich hatte so ein ähnliches Problem hier
http://www.delphipraxis.net/162142-t...cute-wait.html
Die Lösung war damals WaitForMultipleObjects
Delphi-Quellcode:
function ExecAndWait(Filename, Params: string; WindowState: word = SW_SHOWNORMAL): boolean;
var
  ShExecInfo: SHELLEXECUTEINFO;
  r : Cardinal;
  const
  SEE_MASK_NOASYNC= $100;
begin
  Result := false;
  if Filename = 'then
    exit;
  if not FileExists(FileName) then
  Begin
    ShowMessage('Datei nicht existent!');
    Exit;
  End;
  ZeroMemory(@ShExecInfo, SizeOf(ShExecInfo));
  ShExecInfo.Wnd := application.MainFormHandle; //GetForegroundWindow;
  ShExecInfo.cbSize := sizeof(SHELLEXECUTEINFO);
  ShExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_NOASYNC;
  ShExecInfo.lpVerb := 'open';
  ShExecInfo.lpFile := PChar(Filename);
  ShExecInfo.lpParameters := PChar(Params);
  ShExecInfo.lpDirectory := PChar(ExtractFileDir(Filename));
  ShExecInfo.nShow := WindowState;
  Result := ShellExecuteEx(@ShExecInfo);


  try
    if Result then
    begin
      repeat
        R := MsgWaitForMultipleObjects(1, ShExecInfo.hProcess, False, INFINITE,QS_ALLINPUT);
        if r <> WAIT_OBJECT_0 then
          Application.ProcessMessages;
      until r = WAIT_OBJECT_0;
    end
    else
      Showmessage('Fehler beim Starten der Anwendung:' + Filename +
                   #13#10'System Fehler: ' + SysErrorMessage(GetLastError));
  finally
    CloseHandle(ShExecInfo.hProcess);
  end;
end;
Andreas
Nobody goes there anymore. It's too crowded!
  Mit Zitat antworten Zitat
nru

Registriert seit: 30. Mai 2008
Ort: Bonn
40 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: WaitForSingleObject und Child-Prozesse

  Alt 12. Sep 2011, 08:31
Vielen Dank für Eure wirklich guten Antworten.
Hab mich letztlich für QuickAndDirty's Lösungsansatz entschieden, der sehr gut funktioniert.


Gruss
nru
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:13 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz