[DllImport("User32.dll",CharSet= CharSet.Auto)]
public static extern int GetWindowThreadProcessId(IntPtr hwnd,out int ID);
//传入一个应用程序excel对象
public static void Kill(Excel.Application excel)
{
IntPtr t=new IntPtr(excel.Hwnd);
int k=0;
GetWindowThreadProcessId(t,out k);
System.Diagnostics.Process p= System.Diagnostics.Process.GetWindowThreadProcessById(k);
p.Kill();
}
浙公网安备 33010602011771号