views:

17

answers:

1

I want to add a text file as resource in VC++ 2005. I am not able to find text as option in resource template.

Also once added how can I refer to that file while programming?

A: 

That's pretty simple: In your solution, switch to resource view, right click on your RC file, select "Add Resource", click on "Import", select "All files" then open the file you want. You're prompted to type in a custom resource type. Enter "TEXT" for example.

You can now load your custom resource like this:

HRSRC hRes = FindResource(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TEXT1), _T("TEXT"));
DWORD dwSize = SizeOfResource(GetModuleHandle(NULL), hRes);
HGLOBAL hGlob = LoadResource(GetModuleHandle(NULL), hRes);
const BYTE* pData = reinterpret_cast<const BYTE*>(::LockResource(hgData));
humbagumba
AfxGetResourceHandle is only available in MFC . Any idea which API I can use in win32?I am creating an exe and all the resources are in that exe.
Alien01
Use GetModuleHandle(NULL). Changed my answer accordingly.
humbagumba