ISTFolder :: ParseDisplayName QT中的Complilation错误

时间:2012-03-26 20:23:17

标签: c++ qt

如果我使用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 :: ParseDispalyName(NULL,NULL,QString *,int,ITEMIDLIST **,NULL)

1 个答案:

答案 0 :(得分:0)

当(我相信)QString期望指向ParseDisplayName时,您正在向wchar_t传递指针。尝试:

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