Announcement

Collapse
No announcement yet.

Find parent process

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Find parent process

    Is there a way to identify the process that launch my application (exe / dll) ?
    - Manual start,
    - Other app or dll,
    - Task manager,
    - etc ...

  • #2
    By using the Toolhelp functions...
    - CreateToolHelp32Snapshot
    - Process32First/Next

    ... you can get the parent process of your current process, which can get you the primary executable module name associated with same (GetModuleBaseName or EnumProcessModules or Module32/Firstnext).

    But what are you trying to accomplish? This topic has come up here before, and IIRC it has always involved something like, "If started from <X> I [do | do not] want to allow some feature of my application to work." And if I continue to remember correctly, this problem was always solved some other way.

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by Michael Mattias View Post
      ...
      But what are you trying to accomplish?
      MCM
      I need to know what is the parent process and decide if it has or not
      permission to execute my process.

      Comment


      • #4
        If this program is only permitted to be executed as a child of some process, an easier way to accomplish this would be to have the parent program create a mutex, and the child process see if it can find that mutex. If it can't, you just end the child process doing nothing.

        Basically you are using the same technology you would use to prevent two instances of any program at the same time, but you are using it for another purpose.

        If the situation is not as posited, please describe and I'm sure someone will have some ideas for you.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X