mini explorer, open w/ shell, prevent zombie proc

This commit is contained in:
Basile Burg 2017-02-18 21:54:00 +01:00
parent 0aefd3341c
commit afe9f0088b
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 11 additions and 15 deletions

View File

@ -208,7 +208,7 @@ type
(**
* Lets the shell open a file.
*)
function shellOpen(const fname: string): boolean;
function shellOpen(const fname: string; wait: boolean = true): boolean;
(**
* Returns true if anExeName can be spawn without its full path.
@ -895,33 +895,29 @@ begin
{$ENDIF}
end;
function shellOpen(const fname: string): boolean;
function shellOpen(const fname: string; wait: boolean = true): boolean;
begin
{$IFDEF WINDOWS}
result := ShellExecute(0, 'OPEN', PChar(fname), nil, nil, SW_SHOW) > 32;
{$ENDIF}
{$IFDEF LINUX}
with TProcess.Create(nil) do
try
{$IFDEF LINUX}
Executable := 'xdg-open';
{$ELSE}
{$IFDEF DARWIN}
Executable := 'open';
{$ENDIF}
{$ENDIF}
Parameters.Add(fname);
Execute;
if wait then
while Running do
sleep(1);
finally
result := true;
Free;
end;
{$ENDIF}
{$IFDEF DARWIN}
with TProcess.Create(nil) do
try
Executable := 'open';
Parameters.Add(aFilename);
Execute;
finally
result := true;
Free;
end;
{$ENDIF}
end;
function exeInSysPath(fname: string): boolean;