- 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()
This commit is contained in:
Martin Fuchs 2003-12-30 19:24:22 +00:00 committed by Alexandre Julliard
parent c02488b5f0
commit 963dd34ec0
4 changed files with 53 additions and 30 deletions

View File

@ -1224,7 +1224,7 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
* *
* NOTES * NOTES
* NULL returns FALSE * NULL returns FALSE
* desktop pidl gives path to desktopdirectory back * desktop pidl gives path to desktop directory back
* special pidls returning FALSE * special pidls returning FALSE
*/ */
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) 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); TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
pdump(pidl); pdump(pidl);
if (!pidl) return FALSE; if (!pidl)
return FALSE;
hr = SHGetDesktopFolder(&shellfolder); hr = SHGetDesktopFolder(&shellfolder);
if (SUCCEEDED (hr)) { if (SUCCEEDED (hr)) {
hr = IShellFolder_GetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&str); hr = IShellFolder_GetDisplayNameOf(shellfolder, pidl, SHGDN_FORPARSING, &str);
if(SUCCEEDED(hr)) { if(SUCCEEDED(hr)) {
StrRetToStrNA (pszPath, MAX_PATH, &str, pidl); StrRetToStrNA (pszPath, MAX_PATH, &str, pidl);
} }
IShellFolder_Release(shellfolder); 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); TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
return SUCCEEDED(hr); return SUCCEEDED(hr);
} }
@ -1273,6 +1280,12 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
IShellFolder_Release(shellfolder); 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); TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
return SUCCEEDED(hr); return SUCCEEDED(hr);
} }

View File

@ -46,3 +46,11 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut); LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut);
HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); 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]);
}

View File

@ -235,7 +235,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
len = lstrlenA(szPath); len = lstrlenA(szPath);
WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL);
pidlTemp = _ILCreateFromPathA(szPath); pidlTemp = _ILCreateFromPathA(szPath);
szNext = lpszDisplayName; szNext = NULL;
} }
if (pidlTemp) { if (pidlTemp) {
@ -449,17 +449,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
* NOTES * NOTES
* special case: pidl = null gives desktop-name back * 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, static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet) LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
{ {
@ -499,7 +488,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
char szRegPath[100]; char szRegPath[100];
lstrcpyA (szRegPath, "CLSID\\"); lstrcpyA (szRegPath, "CLSID\\");
__SHGUIDToStringA (clsid, &szRegPath[6]); SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
lstrcatA (szRegPath, "\\shellfolder"); lstrcatA (szRegPath, "\\shellfolder");
bWantsForParsing = bWantsForParsing =
(ERROR_SUCCESS == (ERROR_SUCCESS ==
@ -512,7 +501,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
} else { } else {
/* parsing name like ::{...} */ /* parsing name like ::{...} */
lstrcpyA (szPath, "::"); lstrcpyA (szPath, "::");
__SHGUIDToStringA (clsid, &szPath[2]); SHELL32_GUIDToStringA (clsid, &szPath[2]);
} }
} else { } else {
/* user friendly name */ /* user friendly name */

View File

@ -199,7 +199,8 @@ ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
LPCWSTR szNext = NULL; LPCWSTR szNext = NULL;
WCHAR szElement[MAX_PATH]; WCHAR szElement[MAX_PATH];
CHAR szTempA[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", TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes); This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
@ -208,23 +209,31 @@ ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
if (pchEaten) if (pchEaten)
*pchEaten = 0; /* strange but like the original */ *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 ? */ /* 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); szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL); WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
pidlTemp = _ILCreateDrive (szTempA); 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;
}
*ppidl = pidlTemp;
} }
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;
}
*ppidl = pidlTemp;
TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr); TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
return hr; return hr;
@ -440,7 +449,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface,
bSimplePidl = _ILIsPidlSimple (pidl); 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 */ /* take names of special folders only if its only this folder */
if (bSimplePidl) { if (bSimplePidl) {
_ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */