MFC中如何获取添加的资源

来源:互联网 发布:二手淘宝店铺安全吗 编辑:程序博客网 时间:2024/06/10 23:06

HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(uiID), strType); 

HRSRC hr = ::FindResource(hInst, MAKEINTRESOURCE(uiID), _T("Files")); 

if (NULL == hr) { FreeResource(hInst); return FALSE;}

HGLOBAL hg = LoadResource(hInst, hr);

if (NULL == hg) { FreeResource(hg); return FALSE;}

LPVOID pv = (PSZ)LockResource(hg);

if(NULL == pv) { FreeResource(hr); return FALSE;}

 

CString strResBuffer = (char*)pv;

 

//释放打开的资源

UnlockResource(hg);

FreeResource(hg);

FreeResource(hr);

原创粉丝点击