Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HINSTANCE to HWND

Tags:

c++

winapi

I use ShellExecute to create a new app instance from my current app. I want to get the HWND of that app. Is it possible to get HWND from HINSTANCE or I need to use EnumWindows?

like image 576
Mircea Ispas Avatar asked Mar 04 '11 10:03

Mircea Ispas


People also ask

What is an HWND?

HWND is a "handle to a window" and is part of the Win32 API . HWNDs are essentially pointers (IntPtr) with values that make them (sort of) point to a window-structure data. In general HWNDs are part an example for applying the ADT model. If you want a Control's HWND see Control. Handle property.

What is hInstance?

hInstance is something called a "handle to an instance" or "handle to a module." The operating system uses this value to identify the executable (EXE) when it is loaded in memory. The instance handle is needed for certain Windows functions—for example, to load icons or bitmaps.


2 Answers

you're right, you need to enum your windows

this question will help you further

like image 135
Tom Avatar answered Oct 05 '22 22:10

Tom


An application does not have a single HWND. Each window within the app has its own handle, an HWND.

You will need to use EnumWindows() or one of its friends.

like image 33
David Heffernan Avatar answered Oct 06 '22 00:10

David Heffernan