当我们使用Excel操作时候,发现总是不能退出,可以这么办
IntPtr t = new IntPtr(xlsApplication.Hwnd);
int k = 0;
GetWindowThreadProcessId(t, out k);
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(k);
p.Kill();