C# Interop Excel 開啟檔案關閉後刪除遺留的Excel process .
[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
uint _pid = 0;
GetWindowThreadProcessId(new IntPtr(ExcelApp.Hwnd), out _pid);
Process _processes = Process.GetProcessById((int)_pid);
if (_processes != null) _processes.Kill();