Getting app that told my app to open a file - Programmer

This is a discussion on Getting app that told my app to open a file - Programmer ; I have an application that processes image files. It currently correctly handles not running multiple instances of itself by having the first instance create an exclusive named pipe. When a second instance gets created, the create of the named pipe ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Getting app that told my app to open a file

  1. Getting app that told my app to open a file

    I have an application that processes image files. It currently
    correctly handles not running multiple instances of itself by having
    the first instance create an exclusive named pipe. When a second
    instance gets created, the create of the named pipe fails (hence, it
    knows it's the second instance). At this point, the second instance
    sends the command-line arguments through the pipe to the first running
    instance which is sitting there in a thread waiting for them. Upon
    receipt, it processes the command-line arguments and opens any
    arguments that are images files. The second instance simply dies. It
    works great.

    But what I want do do now is to know which other application triggered
    the launch of my application (either the first or second instance).
    For example, if the user drags & drops an image file onto my app's
    icon, I'd like to know that it was Windows Explorer that triggered the
    launch of my app. If my app is set as the "external editor" of, say
    Adobe Lightroom, then I want to know that it was the Adobe Lightroom
    app that triggered the launch of my app and passed it the name of the
    image file. I want to do different things based on which app triggered
    the launch of my app.

    So can somebody point me in the right direction for how to get
    information about the "triggering" application/process?

    Ideally, I want to use the plain Win32 API from C and not anything .NET
    related.

    Thanks.

    - Paul

  2. Re: Getting app that told my app to open a file

    On Feb 20, 7:39 am, pauljlucas.removet...@removethistoo.mac.com (Paul
    J. Lucas) wrote:
    > I have an application that processes image files. It currently
    > correctly handles not running multiple instances of itself by having
    > the first instance create an exclusive named pipe. When a second
    > instance gets created, the create of the named pipe fails (hence, it
    > knows it's the second instance). At this point, the second instance
    > sends the command-line arguments through the pipe to the first running
    > instance which is sitting there in a thread waiting for them. Upon
    > receipt, it processes the command-line arguments and opens any
    > arguments that are images files. The second instance simply dies. It
    > works great.
    >
    > But what I want do do now is to know which other application triggered
    > the launch of my application (either the first or second instance).
    > For example, if the user drags & drops an image file onto my app's
    > icon, I'd like to know that it was Windows Explorer that triggered the
    > launch of my app. If my app is set as the "external editor" of, say
    > Adobe Lightroom, then I want to know that it was the Adobe Lightroom
    > app that triggered the launch of my app and passed it the name of the
    > image file. I want to do different things based on which app triggered
    > the launch of my app.
    >
    > So can somebody point me in the right direction for how to get
    > information about the "triggering" application/process?
    >
    > Ideally, I want to use the plain Win32 API from C and not anything .NET
    > related.
    >
    > Thanks.
    >
    > - Paul


    You are expecting a trouble. Any application can use ShellExecute() to
    start your service. You will have the explorer (or Windows Shell, if
    you like) as the origin.


+ Reply to Thread