Get Application's Window Handles

前端 未结 3 1399
野趣味
野趣味 2020-11-28 10:14

I\'m building an app that given another app mainWindowhandle it collects information about the window state. I have no problem collecting information about child windows, bu

3条回答
  •  难免孤独
    2020-11-28 10:56

    You could do what Process.MainWindowHandle appears to do: use P/Invoke to call the EnumWindows function, which invokes a callback method for every top-level window in the system.

    In your callback, call GetWindowThreadProcessId, and compare the window's process id with Process.Id; if the process ids match, add the window handle to a list.

提交回复
热议问题