代码如下:
BOOL CPicture::Load(UINT nIDRes)
{
// find resource in resource file
HINSTANCE hInst = AfxGetResourceHandle();
HRSRC hRsrc = ::FindResource(hInst,
MAKEINTRESOURCE(nIDRes),
"IMAGE"); // type
if (!hRsrc)
return FALSE; // load resource into memory
DWORD len = SizeofResource(hInst, hRsrc);
BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);
if (!lpRsrc)
return FALSE; // create memory file and load it
CMemFile file(lpRsrc, len);
BOOL bRet = Load(file);
FreeResource(hRsrc);
GlobalFree(lpRsrc);//这个GlobalFree()能不能这么用
return bRet;
}

解决方案 »

  1.   

    HGLOBAL GlobalFree(
      HGLOBAL hMem   // handle to global memory object
    );Parameters
    hMem 
    [in] Handle to the global memory object. This handle is returned by either the GlobalAlloc or GlobalReAlloc function. 
    lpRsrc不是用GlobalAlloc 或者GlobalReAlloc 来创建的,所以不能用…………
    呵呵,
      

  2.   

    The LoadResource function loads the specified resource into global memory. 那么该指针处的内容如何释放呢