我正在使用SHGetSpecialFolderLocation API函数。我的应用程序设置为“使用Unicode字符集”。C++:在API函数中使用std :: wstring
这是我到目前为止有:
int main (int, char **)
{
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);
/* Confused at this point */
wstring wstrPath;
wstrPath.resize (_MAX_PATH);
BOOL f = SHGetPathFromIDList(pidl, wstrPath.c_str());
/* End confusion */
我得到的错误是:
error C2664: 'SHGetPathFromIDListW' : cannot convert parameter 2 from 'const wchar_t *' to 'LPWSTR'
有人能帮忙吗?什么是适当的C++方法来做到这一点?
谢谢!
与这个问题没有什么关系,但'SHGetSpecialFolderLocation' /'SHGetSpecialFolderPath'已经过时。微软建议'SHGetKnownFolderPath'(http://msdn.microsoft.com/en-us/library/bb762188.aspx),或者,如果你想保持与Windows XP的兼容,'SHGetFolderPath'(http://msdn.microsoft .COM/EN-US /库/ bb762181.aspx)。 – Philipp 2010-06-29 06:56:33