SHGetSpecialFolderPath() 未在此范围内声明

SHGetSpecialFolderPath() Not Declared in This Scope

本文关键字:范围内 声明 SHGetSpecialFolderPath      更新时间:2023-10-16

我无法编译我的程序SHGetSpecialFolderPath()未在程序范围内声明,而包含正确的标头(根据MSDN)http://msdn.microsoft.com/en-us/library/bb762204(v=vs.85).aspx

以下是我的项目的标题:

#include <iostream>
#include <iostream>
#include <windows.h>
#include <algorithm>
#include <vector>
#include <fstream>
#include <direct.h>
#include <shlobj.h>

有错误:C:\Users\user\Documents\getAppData\main.cpp|31|error: 'SHGetSpecialFolderPath' 未在此范围内声明

其中 shlobj.h 是带有声明的标头。知道编译器为什么抛出错误吗?以下是我调用该函数的方式:

char appData[MAX_PATH];
SHGetSpecialFolderPath( NULL
                        ,appData
                        ,CSIDL_LOCAL_APPDATA
                        ,1 );
cout << appData << endl;

谢谢!

从 MSDN 页面:

Microsoft IE浏览器4.0 必须安装 桌面更新 此功能可用。

在 Windows 2000 中,此功能是 被 ShGetFolderPath 取代。您可以 在早期系统上使用此功能 通过包含可再发行的 DLL, ShFolder.dll。

也许这是你的问题?