Launch Services to launch (bring to foreground) an already running application with new arguments

Discussion in 'Mac OS X Development' started by SajasKK, Apr 10, 2014.

  1. SajasKK

    SajasKK Newbie

    I am trying to use Mac Launch Services to open an application from my program. I am using the LSOpenApplication service to do this.
    LSApplicationParameters params ={0,
    OSStatus t =  LSOpenApplication(&params, NULL);
    I was able to launch the application. The application takes a file path to open the file. When the application is getting launched for the first time, it opens the file correctly.

    But if the application is running in background and I try to launch it, it won't open the file passed as argument. And if the applciation is running, my program is not supposed to launch a new process again, instead I should open the file in the already running application. How can I do this?
  2. saud

    saud Administrator Staff Member

    According to documentation:

    The LSOpenApplication launches one application. This function is an updated alternative to the Process Manager's LaunchApplication function. Launch arguments are specified in the inAppParams argument, which must be supplied. If the application is already running in the current session, it is made the front process (unless the kLSLaunchNewInstance flag is used, which always causes a new process to be created).

    Does that seem to help answer? I have not used Mac Launch Services personally.

Share This Page