[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();

}

posted on 2016-09-14 09:33  张小帅  阅读(5291)  评论(0编辑  收藏  举报