How can I perform the equivalent of shellexecute()
in Lazarus for a Mac?
views:
1164answers:
5Since OS X is simply a descendant of BSD Unix, you can use fork() or exec(), whichever is appropriate for your application, IIRC. See the man pages on either of those for more info.
EDITED: Fixed typo to read "BSD Unix" instead of "Linux" and apologized in comments for fat fingers. :-)
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.
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.
{ 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;