|
-
May 11th, 2011, 10:50 AM
#1
Obtain hinstance for hdc
Hi
Is there a way to obtain the hinstance of my program from the hdc value??
Just poking around!
-
May 11th, 2011, 11:08 AM
#2
Re: Obtain hinstance for hdc
 Originally Posted by vinayak4gargya
Is there a way to obtain the hinstance of my program from the hdc value??
Sure, and you don't even need hdc for that.
Your hInstance most likely is 0x00400000. Check in your debugger!
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
May 11th, 2011, 11:09 AM
#3
Re: Obtain hinstance for hdc
Yeah. Use ::WindowFromDC(HDC) to get the HWND, then use ::GetWindowLong(HWND, GWL_HINSTANCE) to get the instance handle.
--EJMW
-
May 11th, 2011, 11:24 AM
#4
Re: Obtain hinstance for hdc
Note also that ::WindowFromDC can return NULL if no window is associated with the specified DC.
Victor Nijegorodov
-
May 11th, 2011, 12:04 PM
#5
Re: Obtain hinstance for hdc
 Originally Posted by vinayak4gargya
Is there a way to obtain the hinstance of my program from the hdc value??
No.
hinstance & hdc = granny & machinegun
-
May 11th, 2011, 12:31 PM
#6
Re: Obtain hinstance for hdc
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.
Last edited by ahmd; May 11th, 2011 at 12:36 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|