Is it possible to get the hInst variable without getting it from the WinMain function. I mean is there a function I can call to just get the instance handle?
Is it possible to get the hInst variable without getting it from the WinMain function. I mean is there a function I can call to just get the instance handle?
#include <windows.h>
hInst = GetModuleHandle(NULL);
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
Gottcha. Thx.
Hmm...to do this I use
hInst = GetWindowLong(hwnd, GWL_HINSTANCE);
I'm not sure if this syntax is totally correct, but it's the idea.
Look up this function. I know you don't want to do this in WinMain, but you can create a global HINSTANCE and just define it to be the first param of WinMain if you like. Then, it can be accessed anywhere.
Garfield
1978 Silver Anniversary Corvette
>> but you can create a global HINSTANCE and just define it to be the first param of WinMain
This seems to be a pretty common practice, espically among the code samples from microsoft. Isn't that supposed to be some sort of deadly sin in programming (as in using a global variable)?
Depends on the program......if it is a game then it is better to have global variable than to pass them to each function as it is much faster.....Originally posted by shtarker
>> Isn't that supposed to be some sort of deadly sin in programming (as in using a global variable)?
Yeah, if you have like 30 global variables declared. It is just an organization thing, as far as I'm concerned, and it's easier to do that with a globa HINSTANCE.
1978 Silver Anniversary Corvette