When using resources without a bitmap, I based my code on codeproject .
IStream* pStream = NULL;
::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream)
m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
pStream->Release();
Looking at this code, as soon as you make a stream from a stream to create a bitmap, you call Release()in the stream to remove the counter of links to the stream, thereby linking the lifetime of the stream to the bitmap.
, .