考慮以下代碼:從MS-Word ApplicationClass獲取PID?
using Microsoft.Office.Interop.Word;
ApplicationClass _application = new ApplicationClass();
我可以從由_Application推出Winword.exe進程的PID?
我需要的PID因爲損壞的文件,我不能退出ApplicationClass,甚至使用此代碼:
_application.Quit(ref saveFile, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(_application);
GC.Collect();
GC.WaitForPendingFinalizers();
我不能搜索Winword.exe進程,並殺死它,因爲我會有幾個,我不知道要殺哪一個。如果我可以爲每個ApplicationClass獲取一個PID,那麼我可以殺死正在給我麻煩退出的正確的winword.exe進程。
@Mmyikka你可以發佈`StaticMethods`類嗎? – BrunoLM 2011-11-25 18:27:45
我試過這個,但我所有的文字處理MainWindowTitle都是空的,並將標題設置爲一個字符串似乎沒有影響,我錯過了什麼? – Arvand 2013-09-25 12:58:24