16,556
社区成员
发帖
与我相关
我的任务
分享
[DllImport("User32.dll")]
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId);
public static void KillExcelApp(this excel.Application app)
{
app.Quit();
IntPtr intptr = new IntPtr(app.Hwnd);
int id;
GetWindowThreadProcessId(intptr, out id);
var p = Process.GetProcessById(id);
//if (p != null)
p.Kill();
}