-
GetModuleHandle
I know that when you are not working with any DLL's that GetModuleHandle(0) is a perfect way to retrive hInstance and not have to make it global. However, in the project I'm working on now I am using DLL's and I'm wondering if it is okay to use GetModuleHandle(0) here and if not what is another possibility?
-
Depends on which handle you want. If you want the DLL's handle then you'll need to pass the DDL's name.
gg
-
If working on a DLL you could store the hInstance from DllMain in a global variable. Other methods are discussed here. By my reading of the documentation the following code should also work. By the complicated workarounds posted on the web I suspect it doesn't, but it's worth a try.
Code:
GetModuleFileName(NULL, szModule, MAX_PATH);
GetModuleHandle(szModule);