Hi
Is there a way to obtain the hinstance of my program from the hdc value??
Just poking around!
Printable View
Hi
Is there a way to obtain the hinstance of my program from the hdc value??
Just poking around!
Yeah. Use ::WindowFromDC(HDC) to get the HWND, then use ::GetWindowLong(HWND, GWL_HINSTANCE) to get the instance handle.
Note also that ::WindowFromDC can return NULL if no window is associated with the specified DC.
VladimirF, is technically right -- a handle for HINSTANCE is most likely to be the same value for most 32-bit processes. It is actually passed into your application in the WinMain() function. Technically speaking the HINSTANCE is partially a rudiment that was carried over from 16-bit Windows and by itself could not be used to uniquely identify a process. Here's some information for you to understand what it is used for:
http://blogs.msdn.com/b/oldnewthing/...18/409205.aspx
So if you need to specifically link a resource to a certain process a better way would be to tie it up to a process ID.