C++ #include <gdiplus.h> 导致错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7305614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 16:46:04  来源:igfitidea点击:

#include <gdiplus.h> causes error

c++visual-c++

提问by Sergey

When I include gdiplus.hin a program that compiles well the first(there are many) error I get is:

当我包含gdiplus.h在一个编译良好的程序中时,我得到的第一个(有很多)错误是:

c:\program files (x86)\microsoft sdks\windows\v7.0a\include\GdiplusImaging.h(77): error C2504: 'IUnknown' : base class undefined

Part of GdiplusImaging.h:

GdiplusImaging.h 的一部分:

IImageBytes : public IUnknown  <<< error!
{
public:
     ...

Why it is so? Where is this IUnknown class? And why it's not in GdiplusImaging.h?

为什么会这样?这个 IUnknown 类在哪里?为什么它不在 GdiplusImaging.h 中?

My system is Windows7 x64. VisualStudio 2010.

我的系统是 Windows7 x64。视觉工作室 2010。

Including part:

包括部分:

#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "gdiplus.lib")

回答by SChepurin

These are the standard includes for using GDI+:

这些是使用 GDI+ 的标准包括:

#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")

回答by Cedekasme

You should try to add windows.hand Unknwn.hheader before gdiplus.h

您应该尝试添加windows.hUnknwn.h标题之前gdiplus.h

#include <Unknwn.h>    
#include <windows.h>
#include <gdiplus.h>