Hi everyone, I'm trying to find a valid method to find a hwnd to a window using given process id or process name (something like findwindow in UM).
What options do I have to get from process id/process name to main window handle?
Thanks!
Hi everyone, I'm trying to find a valid method to find a hwnd to a window using given process id or process name (something like findwindow in UM).
What options do I have to get from process id/process name to main window handle?
Thanks!
From kernel mode? That's impossible. UI is entirely a user-mode concept. There is nothing UI-related in the kernel APIs. How would you even get a window handle?
If you're in user mode, you can use EnumWindows to go through the top-level window handles, and GetWindowThreadProcessID to get the process associated with that window.
remembering of course that while most processes have 1 'main' window, there could be zero or multiple. And normally all of the windows will be on the same desktop, but that's not universally true either.
probably, you have some larger goal and you will be better suggestions by sharing it