You are passing NULL
as the hModule
parameter of FindResource()
, LoadResource()
, and SizeofResource()
. Per the FindResource()
and LoadResource()
documentations:
hModule [in, optional]
Type: HMODULE
A handle to the module whose portable executable file or an accompanying MUI file contains the resource. If this parameter is NULL, the function searches the module used to create the current process.
hModule [in, optional]
Type: HMODULE
A handle to the module whose executable file contains the resource. If hModule is NULL, the system loads the resource from the module that was used to create the current process.
(The SizeofResource()
documentation has no such comment, but presumably NULL
also apples to it as well).
A process is not created from a DLL, only from an EXE. So your use of hModule=NULL
is causing the API to search the resources of the EXE that loaded your DLL, not the resources of your DLL.
You need to use the HMODULE
that points to your DLL.
If your loading code is inside the DLL itself, use the HINSTANCE
that is supplied to the DLL's DllMain()
/DllEntryPoint()
:
hinstDLL [in]
A handle to the DLL module. The value is the base address of the DLL. The HINSTANCE of a DLL is the same as the HMODULE of the DLL, so hinstDLL can be used in calls to functions that require a module handle.
If the loading code is inside the EXE instead (or in another DLL), you will have to use the HMODULE
that is returned by LoadLibrary()
or GetModuleHandle()
.