0

My code for loading the file from resource is given below

    void LoadFileInResource(int name, int type, DWORD& size, const char*& data)
{
    HMODULE handle = ::GetModuleHandle(NULL);
    HRSRC rc = ::FindResource(handle, MAKEINTRESOURCE(name),MAKEINTRESOURCE(type));
    HGLOBAL rcData = ::LoadResource(handle, rc);
    size = ::SizeofResource(handle, rc);
    data = static_cast<const char*>(::LockResource(rcData));
}

This code works perfect if its just an application. When the same code is used as a DLL, I am getting null in rc, which is post the FindResource.

I have defined the symbols in resourceful file as shows below:

#define TEXTFILE        256
#define IDR_MYTEXTFILE  105

Also the file which I need to add is defined in rc file:

IDR_MYTEXTFILE TEXTFILE "C:/Docs/Lib.XML"

As I mentioned earlier, this code is perfectly working when its an application, converting it to DLL is creating issue.

LoadFileInResource function is called as given below:

LoadFileInResource(IDR_MYTEXTFILE, TEXTFILE, size, data);
Programmer
  • 329
  • 2
  • 6
  • 25

0 Answers0