Reputation: 427
I have develop a dynamic library, in dll I have added a resource text file and other codes for other purpose, then through a executable I am dynamically loading the dll, when the call goes to FindResource API it always returns NULL. while executable is in separate folder, dynamic library folder is separate one. I can't get why it's not working. code: > HRSRC hRes = FindResource(0, MAKEINTRESOURCE(IDR_XYZ_ABC1), "XYZ_ABC"); <
Upvotes: 0
Views: 1773
Reputation: 51472
Error code 1813 translates to
The specified resource type cannot be found in the image file.
Passing a NULL
as the first argument to FindResource
is documented to mean:
If this parameter is NULL, the function searches the module used to create the current process.
If you want to load a resource from an image you load dynamically into a process you have to pass the module's handle to FindResource
:
HMODULE hMod = LoadLibrary("MyResources.dll");
HRSRC hRes = FindResource(hMod, MAKEINTRESOURCE(IDR_XYZ_ABC1), "XYZ_ABC");
// ...
If your .dll contains resources only you may want to use LoadLibraryEx
instead. It lets you specify additional load options, allowing you to load a library that consists of resources only, without an entry point.
Upvotes: 1
Reputation: 1232
The first parameter of FindResource is the handle to load from. So it could be your dynamic dll handle.
Upvotes: 1