示例#1
0
 /// <returns>成功则返回 true</returns>
 public static bool KillActiveExcelApp(Application appToKill)
 {
     if (appToKill != null)
     {
         try
         {
             // excelApp.Quit();
             var processId = 0;
             var threadId  = Windows.GetWindowThreadProcessId(appToKill.Hwnd, ref processId);
             var pr        = Process.GetProcessById(processId);
             pr.Kill();
             //
             if (appToKill.Equals(_workingApp))
             {
                 _workingApp = null;
             }
         }
         catch (Exception)
         {
             return(false);
         }
     }
     return(true);
 }