AcidBird
Elite
Lorsque j'essaye de lancer un exécutable à l'aide de la commande CreateProcess, winExec ou ShellExecute, le process est bien créé (il apparait dans la liste des process du task manager) mais le programme ne s'affiche jamais (rien n'apparait à l'écran). Quelqu'un a-t-il une idée d'ou cela pourrait provenir ?
Voila les différents code que j'utilise pour lancer des exe à partir d'un autre programme et qui a toujours fonctionné jusqu'à présent ...
ShellExexute :
....
shellExecute(self.Handle, PChar('open'),pChar(FileToExec),nil,nil ,SW_MAXIMIZE);
...
WinExec :
...
WinExec(pChar(FileToExec), SW_MAXIMIZE);
...
CreateProcess :
function ExecuteProgram( const ProgramName: String;
WaitUntilGone: Boolean;
var ID: Integer; {instance handle or process ID}
var Active: Boolean ): Boolean;
var
TSI: TStartupInfo;
TPI: TProcessInformation;
ECP: DWord;
begin
Result := False;
Active := True;
try
FillChar(TSI, SizeOf(TSI), 0);
TSI.CB := SizeOf(TSI);
if CreateProcess(PChar(ProgramName), nil, nil, nil, False,
DETACHED_PROCESS OR NORMAL_PRIORITY_CLASS, nil, nil, TSI, TPI) then
begin
ID := TPI.dwProcessID;
CloseHandle(TPI.hThread);
WaitForInputIdle(TPI.hProcess, 10000); {let process start!}
if WaitUntilGone then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(TPI.hProcess, ECP);
until (ECP <> STILL_ACTIVE) or Application.Terminated;
CloseHandle(TPI.hProcess);
end;
Result := True;
end;
finally
Active := False;
end;
end;
Voila les différents code que j'utilise pour lancer des exe à partir d'un autre programme et qui a toujours fonctionné jusqu'à présent ...
ShellExexute :
....
shellExecute(self.Handle, PChar('open'),pChar(FileToExec),nil,nil ,SW_MAXIMIZE);
...
WinExec :
...
WinExec(pChar(FileToExec), SW_MAXIMIZE);
...
CreateProcess :
function ExecuteProgram( const ProgramName: String;
WaitUntilGone: Boolean;
var ID: Integer; {instance handle or process ID}
var Active: Boolean ): Boolean;
var
TSI: TStartupInfo;
TPI: TProcessInformation;
ECP: DWord;
begin
Result := False;
Active := True;
try
FillChar(TSI, SizeOf(TSI), 0);
TSI.CB := SizeOf(TSI);
if CreateProcess(PChar(ProgramName), nil, nil, nil, False,
DETACHED_PROCESS OR NORMAL_PRIORITY_CLASS, nil, nil, TSI, TPI) then
begin
ID := TPI.dwProcessID;
CloseHandle(TPI.hThread);
WaitForInputIdle(TPI.hProcess, 10000); {let process start!}
if WaitUntilGone then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(TPI.hProcess, ECP);
until (ECP <> STILL_ACTIVE) or Application.Terminated;
CloseHandle(TPI.hProcess);
end;
Result := True;
end;
finally
Active := False;
end;
end;