Consider this code:
using Microsoft.Office.Interop.Word;
ApplicationClass _application = new ApplicationClass();
Can I get the PID from the Winword.exe process that was launched by the _application?
I need the PID because with corrupted files, I just can't quit the ApplicationClass, even using this code:
_application.Quit(ref saveFile, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(_application);
GC.Collect();
GC.WaitForPendingFinalizers();
I can't search for the winword.exe process and kill it, because I will have several, and I don't know which one to kill. If I can get a PID for each ApplicationClass, I could just kill the correct winword.exe process that is giving me troubles to quit.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…