我已经学习Java编程大约7个月了,我对c ++感兴趣.我目前正在阅读一本c ++书.
我正在使用eclipse c ++,因为我对eclipse非常熟悉.
我用c ++制作了6个项目(小项目),到目前为止一切都很好.
我的问题是我无法使SHGetKnownFolderPath方法起作用.完整的行是红色的,尽管我已导入所有内容,构建它,尝试运行它.我已经检查过网站,我使用了与其他人相同的代码,但仍然没有为我工作.
它说:无法解析函数SHGetKnownFolderPath
我在64位Windows 8计算机上.这是代码: UPDATE
#define WINVER 0x0600 // 0x06020000 0x06030000
#include <shlobj.h>
#include <windows.h>
#include <combaseapi.h>
#include <comutil.h> //for _bstr_t (used in the string conversion)
#include <knownfolders.h>
#include <winerror.h> //for HRESULT
#include <winnt.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
LPWSTR wszPath = NULL;
HRESULT hr;
hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &wszPath);// THIS LINE IS COMPLETELY RED
if (SUCCEEDED(hr)){
_bstr_t bstrPath(wszPath);
std::string strPath((char*)bstrPath);
std::cout << strPath;
}
CoTaskMemFree(wszPath);
return …
Run Code Online (Sandbox Code Playgroud)