0

I have an app that will usually be spawned by another app. The UI and behaviour will vary a bit depending on whether the said app was opened directly by the user or spawned. How can I determine if it was launched by the user or spawned?

I have a couple of ideas but they don't seem doable.

  1. If there was a way of sending extra app specific param via CreateProcess() this would be simple but I can't find how to do that.

  2. If I can find the handle of the parent process, I can determine if it was spawned or not but I can't see how to do that.

Please help!

nick
  • 1
  • possible duplicate of [How can a Win32 process get the pid of its parent?](http://stackoverflow.com/questions/185254/how-can-a-win32-process-get-the-pid-of-its-parent) – unwind Apr 27 '11 at 11:47
  • Not a duplicate as there are better solutions to the problem than finding the parent process. – interjay Apr 27 '11 at 11:52

1 Answers1

1

If there was a way of sending extra app specific param via CreateProcess()

So you have control of the invoking application? If so surely this is what command lines are for?

CreateProcess( NULL, "C:\\app.exe /launched_by_app2" ...)
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • I think you're supposed to repeat the program name as the first command-line parameter in CreateProcess. – interjay Apr 27 '11 at 11:51