Hi there,
The following codes are got from http://msdn2.microsoft.com/en-us/library/ms534078.aspx. But when it is compiled with VC 6.00 with February 2003 SDK, 102 errors are showed up as below. What's the problem? How is it resolved?
Thanks,
Code:
#include "stdafx.h"
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
INT main()
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
UINT num; // number of image decoders
UINT size; // size, in bytes, of the image decoder array
ImageCodecInfo* pImageCodecInfo;
// How many decoders are there?
// How big (in bytes) is the array of all ImageCodecInfo objects?
GetImageDecodersSize(&num, &size);
// Create a buffer large enough to hold the array of ImageCodecInfo
// objects that will be returned by GetImageDecoders.
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
// GetImageDecoders creates an array of ImageCodecInfo objects
// and copies that array into a previously allocated buffer.
// The third argument, imageCodecInfos, is a pointer to that buffer.
GetImageDecoders(num, size, pImageCodecInfo);
// Display the graphics file format (MimeType)
// for each ImageCodecInfo object.
for(UINT j = 0; j < num; ++j)
{
wprintf(L"%s\n", pImageCodecInfo[j].MimeType);
}
free(pImageCodecInfo);
GdiplusShutdown(gdiplusToken);
return 0;
}
Compiling Errors:
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2440: 'initializing' : cannot convert from 'char [37]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2501: 'IImageBytes' : missing storage-class or type specifiers
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2239: unexpected token ':' following declaration of 'IImageBytes'
d:\program files\microsoft sdk\include\gdiplusimaging.h(67) : error C2059: syntax error : 'public'
d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2146: syntax error : missing ';' before identifier 'id'
d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2501: 'PROPID' : missing storage-class or type specifiers
d:\program files\microsoft sdk\include\gdiplusimaging.h(246) : error C2501: 'id' : missing storage-class or type specifiers
d:\program files\microsoft sdk\include\gdiplusheaders.h(384) : error C2629: unexpected 'class Gdiplus::Image ('
d:\program files\microsoft sdk\include\gdiplusheaders.h(384) : error C2238: unexpected token(s) preceding ';'
d:\program files\microsoft sdk\include\gdiplusheaders.h(395) : error C2061: syntax error : identifier 'IStream'
d:\program files\microsoft sdk\include\gdiplusheaders.h(405) : error C2061: syntax error : identifier 'IStream'
d:\program files\microsoft sdk\include\gdiplusheaders.h(443) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusheaders.h(444) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusheaders.h(445) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusheaders.h(453) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusheaders.h(499) : error C2629: unexpected 'class Gdiplus::Bitmap ('
d:\program files\microsoft sdk\include\gdiplusheaders.h(499) : error C2238: unexpected token(s) preceding ';'
d:\program files\microsoft sdk\include\gdiplusheaders.h(510) : error C2061: syntax error : identifier 'IStream'
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'IStream' : undeclared identifier
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'stream' : undeclared identifier
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2065: 'image' : undeclared identifier
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2100: illegal indirection
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2275: 'GpImage' : illegal use of this type as an expression
d:\program files\microsoft sdk\include\gdiplusgpstubs.h(61) : see declaration of 'GpImage'
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : warning C4229: anachronism used : modifiers on data are ignored
d:\program files\microsoft sdk\include\gdiplusflat.h(1133) : error C2078: too many initializers
d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2100: illegal indirection
d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2275: 'GpImage' : illegal use of this type as an expression
d:\program files\microsoft sdk\include\gdiplusgpstubs.h(61) : see declaration of 'GpImage'
d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : warning C4229: anachronism used : modifiers on data are ignored
d:\program files\microsoft sdk\include\gdiplusflat.h(1139) : error C2078: too many initializers
d:\program files\microsoft sdk\include\gdiplusflat.h(1156) : error C2061: syntax error : identifier 'IStream'
d:\program files\microsoft sdk\include\gdiplusflat.h(1244) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusflat.h(1247) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusflat.h(1250) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusflat.h(1262) : error C2061: syntax error : identifier 'PROPID'
d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2065: 'bitmap' : undeclared identifier
d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2100: illegal indirection
d:\program files\microsoft sdk\include\gdiplusflat.h(1275) : error C2275: 'GpBitmap' : illegal use of this type as an expression
d:\program files\microsoft sdk\include\gdiplusgpstubs.h(62) : see declaration of 'GpBitmap'