2

I have an application which supports out-of-process COM automation. Now, I want it to be able to behave differently when it is launched by user and when it is started by COM to serve an automation request. How can I distinguish these cases from within the application?

Googling has brought me nothing, and the only idea I have so far is to determine the parent process, but I'm not sure how fragile it would be.

vines
  • 4,959
  • 1
  • 24
  • 47
  • 2
    Perhaps you look for this command line parameter: [COM appends the "-Embedding" flag to the string, so the application that uses flags must parse the whole string and check for the -Embedding flag.](https://msdn.microsoft.com/en-us/library/windows/desktop/ms686595) – Roman R. Mar 14 '18 at 11:40
  • @RomanR. Ah, exactly. Wonder where my eyes were... Thank you! Care to post this as an answer so I could accept it? – vines Mar 14 '18 at 12:07

1 Answers1

4

When COM launches local out-of-process server, it looks up registry for the hosting process path and appends "-Embedding" command line parameter. This is where you are supposed to look at to, respectively, detect COM launch.

The behavior is documented here:

COM appends the "-Embedding" flag to the string, so the application that uses flags needs to parse the whole string and check for the -Embedding flag.

Roman R.
  • 64,446
  • 5
  • 83
  • 139