I\'m writing a DLL in VC++ and I need to use external text file. I have something like this right now:
ifstream file;
string line;
file.open(\"C:\\\\User
Assumptions:
Loading a resource into memory and getting a pointer to it is done like this:
HRSRC hResource = FindResource(m_hInstance, MAKEINTRESOURCE(MY_RESOURCE_ID), L"TEXT");
if (hResource)
{
HGLOBAL hLoadedResource = LoadResource(m_hInstance, hResource);
if (hLoadedResource)
{
LPVOID pLockedResource = LockResource(hLoadedResource);
if (pLockedResource)
{
DWORD dwResourceSize = SizeofResource(m_hInstance, hResource);
if (0 != dwResourceSize)
{
// Use pLockedResource and dwResourceSize however you want
}
}
}
}
Note: You do not have to unload or unlock the resource on 32-bit or 64-bit vesions of Windows, and if you obtain the resource again you will not leak memory; you always get the same piece of memory.
For updating a resource, see Updating Resources in MSDN.