How can I perform the equivalent of shellexecute()
in Lazarus for a Mac?
{ Here is code to do it. Use the TProcess object! }
uses Process;
...
procedure DoProcess;
Var
Proc : TProcess;
Begin
Proc := TProcess.Create(nil);
try
Proc.CommandLine := '/Applications/MyApp.app';
PRoc.Options := Proc.Options + [poWaitOnExit];
Proc.CommandLine := Proc.CommandLine + ' -someparam';
PRoc.Execute;
finally
Proc.free;
end;
End;
I don't know whether Lazarus libraries do already have this functionality wrapped, but if not you could write a conditionally compiled version of ShellExecute() using the info in the Launch Services Programming Guide.
If you want to use ShellExecute to open a document with its preferred application, then you can use the OpenDocument procedure from the LCLIntf unit.
The Lazarus conversion tool also uses this replacement for ShellExecute, see the Lazarus wiki. Internally it uses open as mentioned by RobS.
I've successfully used Shell('open ' + Filename)
in OS X 10.4 and 10.3 which seems to work rather nicely for most filetypes.
I stumbled across open
at the shell prompt and now miss it in cygwin/linux etc.
© 2022 - 2024 — McMap. All rights reserved.