【问题标题】:SHGetFolderPath': identifier not foundSHGetFolderPath':找不到标识符
【发布时间】:2011-10-13 09:59:25
【问题描述】:

我正在使用 DirectX 9 On Vs 2008/windows7 做示例。 我遇到了错误。

1>----- 构建开始:项目:VideoCapture,配置:调试 Unicode Win32 ------ 1>正在编译...

1>VideoCaptureDlg.cpp
1>.\VideoCaptureDlg.cpp(169):错误 C2065:“SHGFP_TYPE_CURRENT”:未声明的标识符
1>.\VideoCaptureDlg.cpp(169) : 错误 C3861: 'SHGetFolderPath': 找不到标识符
1>.\VideoCaptureDlg.cpp(173):错误 C2065:“SHGFP_TYPE_CURRENT”:未声明的标识符
1>.\VideoCaptureDlg.cpp(173):错误 C3861:“SHGetFolderPath”:找不到标识符
1>.\VideoCaptureDlg.cpp(1025) : 警告 C4244: 'argument' : 从 'int' 转换为 'WORD',可能丢失数据
1>.\VideoCaptureDlg.cpp(1180):错误 C2065:“SHGFP_TYPE_CURRENT”:未声明的标识符
1>.\VideoCaptureDlg.cpp(1180) : 错误 C3861: 'SHGetFolderPath': 找不到标识符
1>.\VideoCaptureDlg.cpp(1184):错误 C2065:“SHGFP_TYPE_CURRENT”:未声明的标识符
1>.\VideoCaptureDlg.cpp(1184) : error C3861: 'SHGetFolderPath': identifier not found

我也添加了 shlobj.h 和 shell32.lib 仍然显示相同的错误。

我尝试在基于 Windows 7 和 Internet Explorer 8 的 stdafx.h 文件中更改以下宏的值,但它显示冲突“C1189:#error:_WIN32_WINNT 设置与_WIN32_IE 设置冲突”

// 不同平台对应值的最新信息请参考MSDN。

#ifndef WINVER // Allow use of features specific to Windows XP or later.    
#define WINVER 0x0501 // Change this to the appropriate value to target other versions  of Windows.    
#endif    

#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.     
#define _WIN32_WINNT 0x0601 // Change this to the appropriate value to target other versions of Windows.    
#endif      

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.     
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.    
#endif    

#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.    
#define _WIN32_IE 0x0800 // Change this to the appropriate value to target other versions of IE.    
#endif

对此问题的任何建议都会有所帮助。

【问题讨论】:

  • stdafx.h 是的,我在任何包含文件之前进行设置
  • 移动评论以根据触发该错误的原因进行回答。

标签: c++ winapi directx


【解决方案1】:

代码块是来自 MSDN 还是您的 stdafx.h?我只会设置宏而不用弄乱条件(你想覆盖以前的设置)。还要确保在任何包含之前设置它们(尤其是windows.h)。

查看错误消息的来源(sdkddkver.h 的第 263 行):

#if ((_WIN32_WINNT < _WIN32_WINNT_WIN2K) && (_WIN32_IE > _WIN32_IE_IE60SP1))
#error _WIN32_WINNT settings conflicts with _WIN32_IE setting
#endif

没有以您认为的方式设置这些宏。

编辑(根据 cmets):

我会开始我的stdafx.h 文件(并确保它始终是第一个标题;这也是有效的预编译标题所必需的):

#define WINVER 0x0601     // Kernel 6.1 == Windows 7/Server 2008 R2
#define _WIN32_WINNT WINVER
#define _WIN32_IE 0x0800  // IE8

#define NOMINMAX          // Don't define min and max (prefer C++ lib)

【讨论】:

  • 看!我的问题是这个错误“错误C3861:'SHGetFolderPath':找不到标识符”。我在网上搜索我发现根据目标系统更改这些宏的值可以解决问题。那就是为什么我改变了这个值,这就是冲突。任何关于原始错误的建议
  • @DeadMg 宏的价值是什么。OS 是 Windows 7,IE 是 IE 8
【解决方案2】:

问题已解决。 我刚刚更改了项目属性下的预处理器设置--> c++->

之前
_WINDOWS;WINVER=0x0400;DEBUG;_DEBUG;_WIN32_WINNT=0x400;WIN32;UNICODE

我改成
_WINDOWS;WINVER=0x0600;DEBUG;_DEBUG;_WIN32_WINNT=0x600;WIN32;UNICODE

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-17
    • 2015-03-01
    • 2015-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    相关资源
    最近更新 更多