Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using System.Diagnostics;
  2. using System.Runtime.InteropServices;
  3.  
  4. static class Program
  5. {
  6. [DllImport("user32.dll")]
  7. [return: MarshalAs(UnmanagedType.Bool)]
  8. static extern bool IsWindowVisible(IntPtr hWnd);
  9.  
  10. public static bool IsProcessDead(Process pr)
  11. {
  12. IntPtr hwnd = pr.MainWindowHandle;
  13. if (hwnd == IntPtr.Zero) return true;
  14.  
  15. return !IsWindowVisible(hwnd);
  16. }
  17.  
  18.  
  19.  
  20. void ClearProcesses()
  21. {
  22. Process[] prs=Process.GetProcessesByName("excel");
  23. foreach (Process proc in prs)
  24. {
  25. if(IsProcessDead(proc))proc.Kill();
  26. }
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement