HWND to HMODULE

  • Thread starter Thread starter Abhishek
  • Start date Start date
A

Abhishek

Hi,

how do you convert HWND to HMODULE or if you have the HWND how do u get its
HMODULE.

regards
Abhishek
 
how do you convert HWND to HMODULE or if you have the HWND how do u get its

You don't! There's no direct relationship between the two things.

Dave
 
Abhishek said:
how do you convert HWND to HMODULE or if you have the HWND how do u get
its HMODULE.

Dave's reply is correct, of course; there is no one-to-one mapping between
window handles and module handles so going from module to window is
problematic.

That said,

1) GetWindowThreadProcessId() will map a window to its owning process and
return a process id
2) OpenProcess() takes a process id and returns a process handle
3) EnumProcessModules() takes a process handle and returns a _set_ of
handles; 1 for each module in the process

If you go that route, don't forget to release any resources (handles) you
allocate.

Also, realize that your success in steps 2 and 3 depends on the security
context in which you try to get that information and the security context of
the target process

Regards.
Will
 
Hi,

Abhishek said:
Hi,

how do you convert HWND to HMODULE or if you have the HWND how do u get
its HMODULE.

You might describe your goal to get more help on your issue.
 
Back
Top