I need to load some resource from my DLL (i need to load them from the DLL code), for doing that I\'m using FindResource.
To do that i need the HModule of the DLL.
Depending upon how your software is architected, you may not have access to DllMain or the code that wants the resource may not even know it's inside a DLL or exe!
The DLLMain function is given the DLL's module handle. Store it in a globally accessible variable.
Or, lookup the module based upon a function known to the local code:
// Determine the module handle by locating a function
// you know resides in that DLL or exe
HMODULE hModule;
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCSTR)&myDLLfuncName, &hModule);
HRSRC hRscr = FindResource(hModule, ............);