QT中的IShellFolder::ParseDisplayName编译错误

IShellFolder::ParseDisplayName Complilation Error in QT

本文关键字:编译 错误 ParseDisplayName QT IShellFolder 中的      更新时间:2023-10-16

如果我使用Visual Studio 2010:,下面的代码可以正常工作

IShellFolder *psfParent = NULL;
LPITEMIDLIST pidlSystem = NULL;
HRESULT hr;
QString sPath = "C:\Users\guest\Desktop\kannden"; // for QT
//wchar_t * path = "C:\Users\guest\Desktop\kannden"; for windows
hr = SHGetDesktopFolder(&psfParent);
if (SUCCEEDED(hr)) 
{
hr =psfParent->ParseDisplayName(NULL,NULL, path,0, &pidlSystem,NULL);
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidlSystem, 0);
}

但如果我在QT 4.7中运行代码,我会得到错误:

调用"IShellFolder::ParseDisplayName(NULL,NULL,QString*,int,ITEMIDLIST**,NULL)时没有匹配的函数

您正在传递指向QString的指针,而(我相信)ParseDisplayName需要指向wchar_t的指针。尝试:

hr = psfParent->ParseDisplayName(NULL,NULL, &QString::toWCharArray(sPath),0, &pidlSystem,NULL);