—–
available WindowStates:
SW_SHOWDEFAULT
SW_SHOW
SW_SHOWMINIMIZED
SW_SHOWMAXIMIZED
… look at Windows-API
————
[code lang=”delphi”]function ExecAndWait(const Filename, Params: string;
WindowState: word): boolean;
var
SUInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CmdLine: string;
begin
//Dateinamen in Anführungszeichen wg. langer Dateinamen mit Blanks
CmdLine := ‘”‘ + Filename + ‘”‘ + Params;
FillChar(SUInfo, SizeOf(SUInfo), #0);
with SUInfo do
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := WindowState;
end;
Result := CreateProcess(nil, PChar(CmdLine), nil, nil, FALSE,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(Filename)), SUInfo, ProcInfo);
//Warten bis beendet
if Result then
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;
[/code]
[tags]Delphi, Misc, Files[/tags]
0 Kommentare zu “ExecAndWait (LaunchAppAndWait für Delphi)”