Bonjour, excusez moi après avoir fait du c++ à l'école, ça fait longtemps que je n'ai plus touché à ce langage et je veux m'y mettre maintenant alors j'ai installé tout ce qu'il faut et faire un test pour voir si l'installation est correcte Ok.
Maintenant j'ai pris un code sur le net dans l'intention de le tester .J'ai trois erreurs et je ne sais pas comment les résoudre alors j'ai besoin de vous de m'initier de nouveau à ce langage en commençant par la correction de ces erreurs.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
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
HBITMAP PictureToBitmap(LPBYTE pmem, DWORD nSize)
{
	HRESULT hr;
	CoInitialize(0);
	HBITMAP hbmp_dst = 0;
	HGLOBAL hgbl =(HGLOBAL)GlobalAlloc(GMEM_FIXED, nSize);
 
	memcpy(hgbl, pmem, nSize);
 
	IStream* stream = 0;
	hr = CreateStreamOnHGlobal(hgbl, FALSE, &stream);
	if(!SUCCEEDED(hr) || !stream) goto errPicture;
 
	IPicture* picture = 0;
	hr = OleLoadPicture(stream, nSize, 0, IID_IPicture, (void**)&picture);
	if(!SUCCEEDED(hr) || !picture) goto errPicture;
 
	HBITMAP hbmp_src;
	picture->get_Handle((OLE_HANDLE *)&hbmp_src);
	if(!SUCCEEDED(hr) || !picture) goto errHandle;
 
	BITMAP bmp;
	GetObject(hbmp_src, sizeof bmp, &bmp);
	hbmp_dst = (HBITMAP)CopyImage(hbmp_src, IMAGE_BITMAP, 0, 0, 0);
 
errHandle:
	picture->Release();
errPicture:
	stream->Release();
	GlobalFree(hgbl);
	CoUninitialize();
	return hbmp_dst;
}
erreurs
Compiling: CImage.cpp
In file included from C:\workspace\C\ImAnalyse\Src\CImage.cpp:23:
C:\workspace\C\ImAnalyse\Src\CImage.h:361:7: warning: no newline at end of file
C:\workspace\C\ImAnalyse\Src\CImage.cpp: In function `HBITMAP__* PictureToBitmap(BYTE*, DWORD)':
C:\workspace\C\ImAnalyse\Src\CImage.cpp:599: error: jump to label `errPicture'
C:\workspace\C\ImAnalyse\Src\CImage.cpp:583: error: from here
C:\workspace\C\ImAnalyse\Src\CImage.cpp:585: error: crosses initialization of `IPicture*picture'
Process terminated with status 1 (0 minutes, 3 seconds)
3 errors, 4 warnings