2
votes

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.

1
@RomanR. Ah, exactly. Wonder where my eyes were... Thank you! Care to post this as an answer so I could accept it?vines

1 Answers

4
votes

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.