[DllImport("user32.dll",SetLastError=true)]
static extern int GetWindowThreadProcessId(IntPtr hwnd,out int processid);
调用方法:
Microsoft.office.Interop.Excel.Application exeApp = new Microsoft.office.Interop.Excel.Application();
//各种excel操作
exeApp.Visible = False;
//
if(exeApp != null)
{
exeApp.Quit();
int pid;
GetWindowThreadProcessId(new IntPtr(exeApp.Hwnd),out pid);
System.Diagnostics.Process.GetProcessById(pid).Kill();
}