在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
#region 结束EXCEL.EXE进程的方法 /// <summary> /// 结束EXCEL.EXE进程的方法 /// </summary> /// <param name="m_objExcel">EXCEL对象</param> [DllImport("user32.dll", SetLastError = true)] static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); private static void KillSpecialExcel(Microsoft.Office.Interop.Excel.Application m_objExcel) { try { if (m_objExcel != null) { int lpdwProcessId; GetWindowThreadProcessId(new IntPtr(m_objExcel.Hwnd), out lpdwProcessId); System.Diagnostics.Process.GetProcessById(lpdwProcessId).Kill(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
|
请发表评论