If the caller sets the fDeleteOnRelease parameter to FALSE,then the caller must also free the hGlobal after the final release. Ifthe caller sets the fDeleteOnRelease parameter to TRUE, the finalrelease will automatically free the hGlobal as shown in the followingexample code. if(pData->fDeleteOnRelease)
{
Verify(0==GlobalFree(pData->hGlobal));
}
另外,根据MSDN对CreateStreamOnHGlobal第一个参数的说明,其中有这么一句“The handle must be allocated as movable and nondiscardable”,也就是说,GlobalAlloc应该使用GMEM_MOVEABLE和GMEM_NODISCARD常量。由于GMEM_NODISCARD已经过时所以被忽略了,那么应该只需要设置成GMEM_MOVEABLE就可以了。