code_junkie

.NET (C#): Getting child windows when you only have a process handle or PID?

Nov 10th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public bool IsWindowActive(Int32 PID)
  2. {
  3. return IsWindowActive(Process.GetProcessById(PID));
  4. }
  5.  
  6. [DllImport("user32.dll")]
  7. private static extern
  8. IntPtr GetForegroundWindow();
  9.  
  10. public bool IsWindowActive(Process proc)
  11. {
  12. proc.Refresh();
  13. return proc.MainWindowHandle.Equals(GetForegroundWindow());
  14. }
Add Comment
Please, Sign In to add comment