View Single Post
Light Poster
31Jan2007,11:40  
Akash's Avatar
First Import a .txt file in MFC
and then give some name such as "A"
So its adding as IDR_A1

Then find IDR_A1, U will see #define IDR_A1 129 or different

Then write the code which is given billow in OnInitDialog()

HGLOBAL hResourceLoaded; // handle to loaded resource
HRSRC hRes; // handle/ptr to res. info.
char *lpResLock; // pointer to resource data
DWORD dwSizeRes;
int nResourceId;
unsigned char vv[50000];

ofstream outputFile;


hRes = FindResource(NULL, MAKEINTRESOURCE(129),"A");


hResourceLoaded = LoadResource(NULL, hRes);
lpResLock = (char *) LockResource(hResourceLoaded);
dwSizeRes = SizeofResource(NULL, hRes);
strcpy(vv,lpResLock);
//*vv=*lpResLock;
outputFile.open("C:\\B.txt",1);
outputFile.write((const char *) lpResLock, dwSizeRes);
outputFile.close();

//adding #include <fstream.h>