+ HRESULT hr;
+
+ TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
+ pdump(pidl);
+
+ if (!pidl)
+ return FALSE;
+
+ hr = SHELL_GetPathFromIDListA(pidl, pszPath, MAX_PATH);
+
+ return SUCCEEDED(hr);
+}
+
+/*************************************************************************
+ * SHELL_GetPathFromIDListW
+ */
+HRESULT SHELL_GetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
+{
+ HRESULT hr = S_OK;
+ UINT len;
+
+ pszPath[0]=0;
+
+ /* One case is a PIDL rooted at desktop level */
+ if (_ILIsDesktop(pidl) ||_ILIsValue(pidl) || _ILIsFolder(pidl))
+ {
+ hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE);
+
+ if (SUCCEEDED(hr))
+ PathAddBackslashW(pszPath);
+ }
+ /* The only other valid case is an item ID list beginning at "My Computer" */
+ else if (_ILIsMyComputer(pidl))
+ pidl = ILGetNext(pidl);
+
+ if (SUCCEEDED(hr))
+ {
+ LPSTR txt;
+
+ while(pidl && pidl->mkid.cb)
+ {
+ if (_ILIsSpecialFolder(pidl))
+ {
+ hr = E_INVALIDARG;
+ break;
+ }
+
+ txt = _ILGetTextPointer(pidl);
+ if (!txt)
+ {
+ hr = E_INVALIDARG;
+ break;
+ }
+
+ if (lstrlenA(txt) > pidl->mkid.cb)
+ ERR("pidl %p is borked\n",pidl);
+ len = MultiByteToWideChar(CP_ACP, 0, txt, -1, NULL, 0);
+ if ( (lstrlenW(pszPath) + len) > uOutSize )
+ {
+ hr = E_INVALIDARG;
+ break;
+ }
+
+ MultiByteToWideChar(CP_ACP, 0, txt, -1,
+ &pszPath[lstrlenW(pszPath)], len);
+
+ pidl = ILGetNext(pidl);
+ if (!pidl)
+ {
+ hr = E_INVALIDARG;
+ break;
+ }
+
+ /* Are we at the end and successfully converted the complete PIDL? */
+ if (!pidl->mkid.cb)
+ break;