macoslazarus

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


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


Solution

  • { 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;