- Код: Выделить всё
function Call_ShellExecute(H: THandle; Operation, FileName, Parameters, Directory: string; L6: LongInt): Variant;
{$IfNDef WINDOWS}
var
P: TProcess;
{$EndIf}
begin
{$IfDef WINDOWS}
Operation := UTF8ToSys(Operation);
FileName := UTF8ToSys(FileName);
Parameters := UTF8ToSys(Parameters);
Directory := UTF8ToSys(Directory);
Result := ShellExecute(H, PChar(Operation), PChar(FileName), PChar(Parameters), PChar(Directory), L6);
{$Else}
Result := 0;
P := TProcess.Create(nil);
try
P.ShowWindow := swoShowNormal;
case L6 of
SW_SHOW: P.ShowWindow := swoShow;
SW_MINIMIZE: P.ShowWindow:= swoMinimize;
SW_SHOWMAXIMIZED: P.ShowWindow := swoShowMaximized;
SW_SHOWMINIMIZED: P.ShowWindow := swoShowMinimized;
SW_SHOWDEFAULT: P.ShowWindow := swoShowDefault;
SW_SHOWNOACTIVATE: P.ShowWindow:= swoShowNoActivate;
SW_HIDE: P.ShowWindow:= swoHIDE;
SW_RESTORE: P.ShowWindow := swoRestore;
SW_SHOWNA: P.ShowWindow:= swoShowNA;
SW_SHOWMINNOACTIVE: P.ShowWindow:= swoshowMinNOActive;
end;
P.Options := [];
P.StartupOptions:=[suoUseShowWindow];
P.CurrentDirectory:= Directory;
if Parameters <> '' then FileName := FileName + ' ' + Parameters;
P.CommandLine := FileName;
P.Execute;
finally
P.Free;
end;
{$EndIf}
end;
Для Linux параметр H: THandle и L6: LongInt - значения не имеют и игнорируются.
Пример:
- Код: Выделить всё
var
filemanager: string;
begin
{$ifdef Windows}
filemanager = 'explorer';
{$else}
filemanager = 'thunar';
{$endif}
call_shellexecute(Form.Handel, 'Open', filemanager, DirectoryPath, '', SW_SHOW);
end;
Для линукс, указывать в filemanager, тот файловый менеджер, который установлен в системе, для разных линуксов он разный, thunar - для XFCE.