如果我使用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)
答案 0 :(得分:0)
当(我相信)QString
期望指向ParseDisplayName
时,您正在向wchar_t
传递指针。尝试:
hr = psfParent->ParseDisplayName(NULL,NULL, &QString::toWCharArray(sPath),0, &pidlSystem,NULL);