MFC从资源加载文本
2017-05-15 00:22
176 查看
bool CWizardSheet::GetTextResource(UINT uID, CString& csContent) { HMODULE hModule=GetModuleHandle(NULL); HRSRC hRes = FindResource(hModule,MAKEINTRESOURCE(uID),_T("txt")); if(hRes == NULL) { FreeResource(hRes); } else { HGLOBAL hglobal = LoadResource(hModule,hRes); if(hglobal == NULL) { FreeResource(hglobal); return false; } else { //get text csContent.Format(_T("%s"),(LPVOID)hglobal); } } return true; }
bool CWizardSheet::GetResource(UINT uID, CString csType, CString csOutputPath) { CFile file; HMODULE hModule=GetModuleHandle(NULL); HRSRC hRes = FindResource(hModule,MAKEINTRESOURCE(uID),csType); if(hRes == NULL) { FreeResource(hRes); } else { HGLOBAL hglobal = LoadResource(hModule,hRes); if(hglobal == NULL) { FreeResource(hglobal); return false; } else { //释放文件 LPBYTE lpByte=(LPBYTE)LockResource(hglobal); DWORD dwRcSize=SizeofResource(hModule,hRes); file.Open(csOutputPath,CFile::modeCreate | CFile::modeWrite); file.Write(lpByte,dwRcSize); file.Close(); } } return true; }
相关文章推荐
- 关于VC/MFC不导入资源文件 动态加载GIF动画文件
- MFC加载资源字符串
- MFC加载位图资源的实现
- [require.js插件] text.js异步加载文本资源
- MFC加载纯资源DLL ,常用于实现多语言
- MFC使用自定义资源加载PNG
- [视频资源]微信小程序demo:知乎日报:富文本解析,点击加载更多
- MFC使用自定义资源加载PNG
- [MFC] MFC 用mciSendString加载WAV资源文件
- 基于MFC的Windows多国语版本软件 —— 加载资源dll
- MFC使用自定义资源加载PNG
- MFC中加载位图资源到窗口中
- MFC加载纯资源DLL
- 加载英文资源DLL时应该在主工程里面讲MFC的使用设置为:在共享DLL中使用MFC
- 使用MFC控件图标不会显示或资源不正常加载
- MFC扩展dll,在构造函数中加载资源,导致程序exe启动困难。
- MFC使用自定义资源加载PNG
- MFC 从资源中直接加载文本文件,资源释放到文件
- MFC加载exe资源,程序调用exe功能
- MFC 加载资源文件里的png