title: Determine parent ProcessID in Word when launched via Office Automation
body: <p>This is a bit arcane, so I hope I am being clear. </p>
  
  <p>I have a custom, unmanaged DLL: MYDLL.DLL, that is invoked by Word via a VBA script using Declare Function.</p>
  
  <p>The DLL uses CreateToolhelp32Snapshot to get the Parent ProcessID. I.e., the process that invoked Winword.exe.</p>
  
  <p>It works fine in most situations. For example, </p>
  
  <ul>
  <li><p>If I double-click on the DOCX file, it shows the parent PID as Explorer.exe.</p></li>
  <li><p>If I "Start" the document from a CMD window, it shows the parent PID as CMD.EXE.</p></li>
  <li><p>If I launch Winword.exe from my application, MYAPP.EXE, using ShellExecute, it shows the Parent PID as MYAPP.EXE.</p></li>
  </ul>
  
  <p>So far, so good.</p>
  
  <p>However, if MYAPP.EXE opens the DOCX file via OLE / Office Automation, it shows the Parent PID as SVCHOST.EXE.  MYAPP.EXE is nowhere in the ancestor chain as far as I can see.</p>
  
  <p>Is there any way I can tell what the invoking PID is when launched via OLE / Office Automation?</p>