如何在从VC ++ 6.0转换的VC ++ 2010项目中使用iFileDialog? [英] How do I use iFileDialog in a VC++ 2010 project converted from VC++ 6.0?

查看:652
本文介绍了如何在从VC ++ 6.0转换的VC ++ 2010项目中使用iFileDialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在VC ++ 2010应用程序中使用FileSaveDialog(Common Item Dialog),如下所示:

  IFileDialog * pFileDialog ; 
HRESULT hr = CoCreateInstance(CLSID_FileSaveDialog,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(& pFileDialog));

但是当我把这个代码放入我从VC ++ 6.0转换到VC ++ 2010的项目时以下错误:


错误C2787:'IFileDialog':没有GUID已与此对象关联

$ b $我也会在 IID_PPV_ARGS 宏和浮动错误下得到一个红色波形:

_uuidof的操作数必须具有为其指定了_declspec(uuid('...'))的类或枚举类型


<

我没有在任何一个项目中使用公共语言运行时支持(/ clr)。



如何将GUID与我的对象关联?

解决方案

问题是我设置了一个针对Win XP操作系统。这就是为什么在Vista中引入的功能没有定义。



我有 _WIN32_WINNT = 0x0501 (WinXP)。当我将它改为 0x0600 (Vista)时,定义了IFileDialog。



IFileDialog的定义导致我的原因。它导致我到 ShObjIdl.h 文件,但是IFileDialog定义的部分是灰色的,导致我到 #if(NTDDI_VERSION& = NTDDI_VISTA)有条件。



谢谢!


I am able to use a FileSaveDialog (Common Item Dialog) in a VC++ 2010 app like this:

IFileDialog *pFileDialog;
HRESULT hr = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFileDialog));    

but when I put this code into my project that has been converted from VC++ 6.0 to VC++ 2010 I get the following error:

"error C2787: 'IFileDialog' : no GUID has been associated with this object"

I also get a red squiggle under the IID_PPV_ARGS macro and the float-over error:

"operand of _uuidof must have a class or enum type for which _declspec(uuid('...')) has been specified"

I am NOT using the Common Language Runtime Support (/clr) in either project.

How do I associate a GUID with my object?

解决方案

The problem was that I had set a compiler flag targeting the Win XP OS. That's why a feature introduced in Vista wasn't defined.

I had _WIN32_WINNT = 0x0501 (WinXP). When I changed it to 0x0600 (Vista) the IFileDialog was defined.

Mark, your suggestion about looking into the definition of IFileDialog lead me to the cause. It led me to the ShObjIdl.h file but the section where IFileDialog was defined was greyed out, leading me up to the #if (NTDDI_VERSION >= NTDDI_VISTA) conditional.

Thanks!

这篇关于如何在从VC ++ 6.0转换的VC ++ 2010项目中使用iFileDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆