c++cwinapiwindows

Getting HWND of current Process


I have a process in c++ in which I am using window API. I want to get the HWND of own process. Kindly guide me how can I make it possible.


Solution

  • You are (incorrectly) assuming that a process has only a single HWND. This is not generally true, and therefore Windows can't offer an API to get it. A program could create two windows, and have two HWNDs as a result. OTOH, if your program creates only a single window, it can store that HWND in a global variable.