Home » Category » DotNet Visual C

DotNet Visual C: HWND to HMODULE

206| Thu, 03 Jan 2008 13:07:00 GMT| abhishek| Comments (3)
Hi,

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

regards
Abhishek

Keywords & Tags: hwnd, hmodule, dotnet, visual, .net

URL: http://dotnet.itags.org/visual-c/71148/
 
«« Prev - Next »» 3 helpful answers below.
>how do you convert HWND to HMODULE or if you have the HWND how do u get its
Quote:
Originally Posted by
>HMODULE.

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

Dave

davidlowndes | Thu, 03 Jan 2008 13:09:00 GMT |

Hi,

"Abhishek" <shake...activelement.comwrote in message
news:OMOas5w3GHA.508...TK2MSFTNGP06.phx.gbl...

Quote:
Originally Posted by
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.

--
SvenC

Quote:
Originally Posted by
regards
Abhishek
>

svenc | Thu, 03 Jan 2008 13:10:00 GMT |

"Abhishek" <shake...activelement.comwrote in message
news:OMOas5w3GHA.508...TK2MSFTNGP06.phx.gbl...
Quote:
Originally Posted by
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

williamdepalomvpvc | Thu, 03 Jan 2008 13:10:00 GMT |

DotNet Visual C Hot Answers

DotNet Visual C New questions

DotNet Visual C Related Categories