私は Java プログラミングを約 7 か月間勉強しており、c++ に興味を持つようになりました。私も現在C++の本を読んでいます。
私はEclipseにかなり慣れているので、Eclipse C ++を使用しています。
私はC ++で6つのプロジェクト(小さなもの)のように作成しましたが、今まですべてうまくいきました。
私の問題は、SHGetKnownFolderPath メソッドを機能させることができないことです。すべてをインポートしてビルドし、実行しようとしましたが、完全な行は赤です。私はインターネット サイトをチェックし、他の人が使用しているのと同じコードを使用しましたが、まだ機能していません。
それは言う:関数SHGetKnownFolderPathを解決できませんでした
私はWindows 8コンピューター64ビットを使用しています。コードは次のとおりです 。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 0;
}
ログは次のとおりです。
#pragma comment(lib, "comsuppw")
^
..\src\HelloWorld.cpp: In function 'int main()':
..\src\HelloWorld.cpp:21:64: error: 'SHGetKnownFolderPath' was not declared in this scope
hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &wszPath);
&wszPath の下の最後の括弧を指す小さな矢印があります)
何が間違っている可能性がありますか?私が得ることができるすべての答えやヒントに感謝します。