| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 
 | LPCTSTR pName; LPCTSTR pType = RT_RCDATA; HMODULE hInst = NULL;
 
//Récupération de la ressource : New/IDR_NEW1
         pName = "IDR_NEW1";
	 pType = "NEW";
	 hInst = 0;
 
	HRSRC hResource = ::FindResource( hInst , pName,pType);
	if (!hResource){
 
		return false;
	}
	DWORD imageSize = ::SizeofResource(hInst, hResource);
	if (!imageSize){
 
		return false;
	}
	const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
	if (!pResourceData){
 
		return false;
	}
 
 
 
HGLOBAL m_hBuffer;
	m_hBuffer  = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
 
	if (m_hBuffer)
	{
 
		void* pBuffer = ::GlobalLock(m_hBuffer);
		if (pBuffer)
		{
 
			CopyMemory(pBuffer, pResourceData, imageSize);
 
			IStream* pStream = NULL;
			if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
			{
 
				//récupérer taille buffer
// get the size of the stream
ULARGE_INTEGER ulnSize2;
LARGE_INTEGER lnOffset2;
lnOffset2.QuadPart = 0;
if(pStream->Seek(lnOffset2, STREAM_SEEK_END, &ulnSize2) != S_OK)
{
 
    pStream->Release();
        return S_OK;
}
 
// now move the pointer to the beginning of the file
if(pStream->Seek(lnOffset2, STREAM_SEEK_SET, NULL) != S_OK)
{
 
	pStream->Release();
    return S_OK;
}
 
 
 char *pBuff2 = new char[ulnSize2.QuadPart];
 
    // Read the stream directly into the buffer
    ULONG ulBytesRead2;
    if(pStream->Read(pBuff2, ulnSize2.QuadPart, &ulBytesRead2) != S_OK)
    {
        pStream->Release();
        delete pBuff2;
        return S_OK;
    } | 
Partager