How can I perform the equivalent of shellexecute() in Lazarus for a Mac?
Asked Answered
L

5

7

How can I perform the equivalent of shellexecute() in Lazarus for a Mac?

Laurice answered 26/2, 2009 at 17:54 Comment(0)
C
8

{ 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;
Carolanncarole answered 5/3, 2009 at 19:26 Comment(0)
M
3

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.

Miksen answered 27/2, 2009 at 5:22 Comment(0)
V
3

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.

Vasili answered 19/9, 2011 at 10:43 Comment(0)
H
1

fork hurts on Mac. BSDs use vfork, not fork.

Harbor answered 26/4, 2009 at 17:27 Comment(0)
I
0

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.

Imagination answered 27/2, 2009 at 9:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.