如何读取程序资源里面的文本文件啊.
导入一个文本文件到资源里面,比如ID号为IDR_TXT
CFile file;
file.Open(IDR_TXT,CFile::modeRead)
为什么不行啊,请高人指点.

解决方案 »

  1.   

    The following code snippet get a pointer to the resource
    HRSRC hResLoad = NULL;     // handle to loaded resource 
    HMODULE hExe = NULL;        // handle to existing .EXE file 
    HRSRC hRes = NULL;         // handle/ptr. to res. info. in hExe 
    LPVOID lpResLock = NULL;    // pointer to resource data  hRes = FindResource(hExe, MAKEINTRESOURCE(resid), restype); 
    if (hRes == NULL) 

    return E_FAIL; 

    hResLoad = (HRSRC)LoadResource(hExe, hRes); 
    if (hResLoad == NULL) 

    return E_FAIL; 

    lpResLock = LockResource(hResLoad); 
    if (lpResLock == NULL) 

    return E_FAIL; 

    int fileSize = SizeofResource(hExe, hRes);
    //the text file is stored in lpResLock
      

  2.   

    上面贴错地方了。。
    http://www.yesky.com/436/1883936.shtml