Commit 963dd34e authored by Martin Fuchs's avatar Martin Fuchs Committed by Alexandre Julliard

- correct return value of SHGetPathFromIDList[AW]() for virtual

folders like "My Computer" - correct path parsing in ISF_Desktop_fnParseDisplayName() - handle CLSID paths in ISF_MyComputer_fnParseDisplayName() - return CLSID path in ISF_MyComputer_fnGetDisplayNameOf()
parent c02488b5
......@@ -1224,7 +1224,7 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
*
* NOTES
* NULL returns FALSE
* desktop pidl gives path to desktopdirectory back
* desktop pidl gives path to desktop directory back
* special pidls returning FALSE
*/
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
......@@ -1236,17 +1236,24 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
pdump(pidl);
if (!pidl) return FALSE;
if (!pidl)
return FALSE;
hr = SHGetDesktopFolder(&shellfolder);
if (SUCCEEDED (hr)) {
hr = IShellFolder_GetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&str);
hr = IShellFolder_GetDisplayNameOf(shellfolder, pidl, SHGDN_FORPARSING, &str);
if(SUCCEEDED(hr)) {
StrRetToStrNA (pszPath, MAX_PATH, &str, pidl);
}
IShellFolder_Release(shellfolder);
}
/* don't allow to return displaynames of the form "::{guid}" */
if (pszPath[0]==':' && pszPath[1]==':') {
*pszPath = '\0';
return FALSE;
}
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
return SUCCEEDED(hr);
}
......@@ -1273,6 +1280,12 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
IShellFolder_Release(shellfolder);
}
/* don't allow to return displaynames of the form "::{guid}" */
if (pszPath[0]==':' && pszPath[1]==':') {
*pszPath = '\0';
return FALSE;
}
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
return SUCCEEDED(hr);
}
......
......@@ -46,3 +46,11 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut);
HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
static inline void SHELL32_GUIDToStringA (REFGUID guid, LPSTR str)
{
sprintf(str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
......@@ -235,7 +235,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
len = lstrlenA(szPath);
WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL);
pidlTemp = _ILCreateFromPathA(szPath);
szNext = lpszDisplayName;
szNext = NULL;
}
if (pidlTemp) {
......@@ -449,17 +449,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
* NOTES
* special case: pidl = null gives desktop-name back
*/
DWORD WINAPI __SHGUIDToStringA (REFGUID guid, LPSTR str)
{
CHAR sFormat[52] = "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
return wsprintfA (str, sFormat,
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
{
......@@ -499,7 +488,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
char szRegPath[100];
lstrcpyA (szRegPath, "CLSID\\");
__SHGUIDToStringA (clsid, &szRegPath[6]);
SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
lstrcatA (szRegPath, "\\shellfolder");
bWantsForParsing =
(ERROR_SUCCESS ==
......@@ -512,7 +501,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
} else {
/* parsing name like ::{...} */
lstrcpyA (szPath, "::");
__SHGUIDToStringA (clsid, &szPath[2]);
SHELL32_GUIDToStringA (clsid, &szPath[2]);
}
} else {
/* user friendly name */
......
......@@ -199,7 +199,8 @@ ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
LPCWSTR szNext = NULL;
WCHAR szElement[MAX_PATH];
CHAR szTempA[MAX_PATH];
LPITEMIDLIST pidlTemp;
LPITEMIDLIST pidlTemp = NULL;
CLSID clsid;
TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
......@@ -208,23 +209,31 @@ ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
if (pchEaten)
*pchEaten = 0; /* strange but like the original */
/* handle CLSID paths */
if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
TRACE ("-- element: %s\n", debugstr_w (szElement));
SHCLSIDFromStringW (szElement + 2, &clsid);
pidlTemp = _ILCreate (PT_MYCOMP, &clsid, sizeof (clsid));
}
/* do we have an absolute path name ? */
if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
pidlTemp = _ILCreateDrive (szTempA);
}
if (szNext && *szNext) {
hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else {
if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
}
hr = S_OK;
if (szNext && *szNext) {
hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else {
if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
}
*ppidl = pidlTemp;
hr = S_OK;
}
*ppidl = pidlTemp;
TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
return hr;
......@@ -440,7 +449,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface,
bSimplePidl = _ILIsPidlSimple (pidl);
if (_ILIsSpecialFolder (pidl)) {
if (!pidl->mkid.cb) {
/* parsing name like ::{...} */
lstrcpyA (szPath, "::");
SHELL32_GUIDToStringA(&CLSID_MyComputer, &szPath[2]);
} else if (_ILIsSpecialFolder (pidl)) {
/* take names of special folders only if its only this folder */
if (bSimplePidl) {
_ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment