Autor Beitrag
saxe66
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Mi 25.04.07 13:22 
Hallo liebe Delphianer,

wie kann ich folgendes Problem lösen ...
Ich möchte aus meiner Anwendung ein externes Windows-Programm starten und dessen Ende abwarten. Das heißt, die Daten, die das externe Programm liefert, werden in meinem Programm weiter verarbeitet.
Habe vor Zeiten schonmal eine Routine WinExecAndWait gefunden, diese führt zwar das Programm aus, meine Anwendung läuft aber gnadenlos weiter.

Bräuchte dringend eine Lösung des Problems.

Danke im Voraus ...

Moderiert von user profile iconTino: "Drigende !!!" aus Titel entfernt.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 25.04.07 13:30 
Schau dir mal Suche in der Entwickler-Ecke CREATEPROCESS, Suche in der Entwickler-Ecke WAITFORSINGLEOBJECT und Suche in der Entwickler-Ecke GETEXITCODEPROCESS an.

Moderiert von user profile iconTino: Search-Tags hinzugefügt.

_________________
Bravery calls my name in the sound of the wind in the night...
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 25.04.07 15:20 
Such mal nach Suche in: Delphi-Forum, Delphi-Library SHELLEXECUTEANDWAIT (vllt isses auch so geschrieben: Suche in: Delphi-Forum, Delphi-Library SHELLEXECUTE_ANDWAIT).
Das ist aus genau den Prozeduren die noidic genannt hat zusammengebastelt.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 25.04.07 15:40 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
function TfMain.run_application(strStartCommand: string;
            var iExitCode: integer): boolean;
var
   recProcessInfo: TProcessInformation;
   dwExitCode: dword;
   dwWaitHandle: dword;
   recStartUpInfo: TStartUpInfo;
begin
   dwExitCode := 0;
   fillchar(recStartUpInfo, sizeof(TStartUpInfo), 0);
   recStartUpInfo.cb := sizeof(TStartUpInfo);
   if createprocess(nil, pchar(strStartCommand), nilnil,
                    TRUE, NORMAL_PRIORITY_CLASS, nilnil,
                    recStartUpInfo, recProcessInfo) then
   begin
      repeat
         dwWaitHandle := waitforsingleobject(recProcessInfo.hProcess, 100);
         Application.ProcessMessages;
      until (dwWaitHandle <> WAIT_TIMEOUT) or Application.Terminated;
      GetExitCodeProcess(recProcessInfo.hProcess, dwExitCode);
      iExitCode := dwExitCode;
      Result := TRUE;
   end
   else
      Result := FALSE;
   getlasterror;
   closehandle(recProcessInfo.hProcess);
   closehandle(recProcessInfo.hThread);
end;


Beste Grüße
Tastaro
saxe66 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Do 26.04.07 07:26 
Titel: Danke
Danke für die schnelle Hilfe, jetzt scheint es zu klappen ...