Programming with Microsoft Visual C++.NET 6ed [Electronic resources]

George Shepherd, David Kruglinski

نسخه متنی -صفحه : 319/ 92
نمايش فراداده

Accessing Resources

Resources are contained inside EXEs and DLLs and thus occupy virtual address space that doesn't change during the life of the process. It is therefore easy to read a resource directly. If you need to access a bitmap, for example, you can get the DIB address with code like this:

LPVOID lpvResource = (LPVOID) ::LoadResource(NULL, 
::FindResource(NULL, MAKEINTRESOURCE(IDB_REDBLOCKS), 
RT_BITMAP));

The LoadResource function returns an HGLOBAL value, but you can safely cast it to a pointer.