Imagine I have Firefox and I open Firefox Start Page, then I should have a Window with the title: "Mozilla Firefox Start Page - Mozilla Firefox".
I can find window handle with the code below
HWND hwnd = ::FindWindow(0, _T("Mozilla Firefox Start Page - Mozilla Firefox"));
But what I want is find window handle from the window's exe file's name like this
HWND hwnd = FindWindowFromExe(_T("firefox.exe"));//How to make this function?
Does windows Api has a function like FindWindowFromExe()? If it doesn't, what is the best way to Find window from its exe?
Thanks for reading :)
FindWindow
? – Thermostatics"MozillaWindowClass"
as its class name. If you want to be extra sure, you can then call GetWindowThreadProcessId, and callGetModuleFileNameEx
to find its primary module. – IndiscretionEnumThreadWindows
– RoselaniEnumThreadWindows
for all threads in system, but only in target process (filtered by name). so already - " fewer windows running in single process" not true. also may be enough enumerate windows only for first thread in process - this is depended from final OP goal – RoselaniAppInit_DLLs
registry key. At the end of the day, you cannot make any assumptions. – IndiscretionEnumThreadWindows
(I think). But it may also decide to create a hidden top-level window. This is common for injected threads, because they may need to know, when the user logs off. – Indiscretion