mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
hopefully the last fix for _SHGetPathFromIDListA/W() to be compatible with MS Windows and make control panel icons reappear
svn path=/trunk/; revision=7495
This commit is contained in:
parent
4f28875a40
commit
c7b79d1742
2 changed files with 33 additions and 44 deletions
|
@ -1297,16 +1297,17 @@ HRESULT _SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize)
|
||||||
LPSTR pstr;
|
LPSTR pstr;
|
||||||
LPSTR end = pszPath + uOutSize;
|
LPSTR end = pszPath + uOutSize;
|
||||||
|
|
||||||
if (_ILIsMyComputer(pidl)) { /* optimized loop to retrieve file system paths */
|
/* If the item ID list begins at "My Computer", we can use
|
||||||
|
an optimized loop to retrieve file system paths. */
|
||||||
|
if (_ILIsMyComputer(pidl)) {
|
||||||
LPCITEMIDLIST p = ILGetNext(pidl);
|
LPCITEMIDLIST p = ILGetNext(pidl);
|
||||||
LPSTR txt;
|
LPSTR txt;
|
||||||
|
|
||||||
pstr = pszPath;
|
pstr = pszPath;
|
||||||
end = pszPath + MAX_PATH;
|
|
||||||
|
|
||||||
while(p && p->mkid.cb && pstr<end) {
|
while(p && p->mkid.cb && pstr<end) {
|
||||||
if (_ILIsSpecialFolder(p))
|
if (_ILIsSpecialFolder(p))
|
||||||
break;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
txt = _ILGetTextPointer(p);
|
txt = _ILGetTextPointer(p);
|
||||||
if (!txt)
|
if (!txt)
|
||||||
|
@ -1329,33 +1330,26 @@ HRESULT _SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize)
|
||||||
|
|
||||||
pstr = pszPath;
|
pstr = pszPath;
|
||||||
|
|
||||||
hr = SHGetDesktopFolder(&desktop);
|
/* The only other valid case is a simple PIDL rooted at desktop level */
|
||||||
|
if (_ILIsValue(pidl) && _ILIsPidlSimple(pidl)) {
|
||||||
|
hr = SHGetDesktopFolder(&desktop);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
if (_ILIsValue(pidl)) {
|
|
||||||
hr = SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOP, FALSE);
|
hr = SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOP, FALSE);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
pstr = PathAddBackslashA(pszPath);
|
pstr = PathAddBackslashA(pszPath);
|
||||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IShellFolder_Release(desktop);
|
||||||
}
|
}
|
||||||
else
|
} else
|
||||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
return E_INVALIDARG;
|
||||||
|
|
||||||
IShellFolder_Release(desktop);
|
if (SUCCEEDED(hr))
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
hr = StrRetToStrNA(pstr, end-pstr, &str, pidl);
|
hr = StrRetToStrNA(pstr, end-pstr, &str, pidl);
|
||||||
|
|
||||||
/* don't allow to return displaynames of the form "::{guid}" */
|
|
||||||
if (pstr[0]==':' && pstr[1]==':') {
|
|
||||||
*pszPath = '\0';
|
|
||||||
hr = E_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
|
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1395,9 @@ HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
||||||
LPWSTR pstr;
|
LPWSTR pstr;
|
||||||
LPWSTR end = pszPath + uOutSize;
|
LPWSTR end = pszPath + uOutSize;
|
||||||
|
|
||||||
if (_ILIsMyComputer(pidl)) { /* optimized loop to retrieve file system paths */
|
/* If the item ID list begins at "My Computer", we can use
|
||||||
|
an optimized loop to retrieve file system paths. */
|
||||||
|
if (_ILIsMyComputer(pidl)) {
|
||||||
LPCITEMIDLIST p = ILGetNext(pidl);
|
LPCITEMIDLIST p = ILGetNext(pidl);
|
||||||
LPSTR txt;
|
LPSTR txt;
|
||||||
|
|
||||||
|
@ -1409,7 +1405,7 @@ HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
||||||
|
|
||||||
while(p && p->mkid.cb && pstr<end) {
|
while(p && p->mkid.cb && pstr<end) {
|
||||||
if (_ILIsSpecialFolder(p))
|
if (_ILIsSpecialFolder(p))
|
||||||
break;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
txt = _ILGetTextPointer(p);
|
txt = _ILGetTextPointer(p);
|
||||||
if (!txt)
|
if (!txt)
|
||||||
|
@ -1433,33 +1429,26 @@ HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
||||||
|
|
||||||
pstr = pszPath;
|
pstr = pszPath;
|
||||||
|
|
||||||
hr = SHGetDesktopFolder(&desktop);
|
/* The only other valid case is a simple PIDL rooted at desktop level */
|
||||||
|
if (_ILIsValue(pidl) && _ILIsPidlSimple(pidl)) {
|
||||||
|
hr = SHGetDesktopFolder(&desktop);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
if (_ILIsValue(pidl)) {
|
|
||||||
hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE);
|
hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
pstr = PathAddBackslashW(pszPath);
|
pstr = PathAddBackslashW(pszPath);
|
||||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IShellFolder_Release(desktop);
|
||||||
}
|
}
|
||||||
else
|
} else
|
||||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
return E_INVALIDARG;
|
||||||
|
|
||||||
IShellFolder_Release(desktop);
|
if (SUCCEEDED(hr))
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
hr = StrRetToStrNW(pstr, end-pstr, &str, pidl);
|
hr = StrRetToStrNW(pstr, end-pstr, &str, pidl);
|
||||||
|
|
||||||
/* don't allow to return displaynames of the form "::{guid}" */
|
|
||||||
if (pstr[0]==':' && pstr[1]==':') {
|
|
||||||
*pszPath = '\0';
|
|
||||||
hr = E_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
|
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,13 @@ static ICOM_VTABLE(IShellExecuteHookW) vt_ShellExecuteHookW;
|
||||||
static ICOM_VTABLE(IShellExecuteHookA) vt_ShellExecuteHookA;
|
static ICOM_VTABLE(IShellExecuteHookA) vt_ShellExecuteHookA;
|
||||||
|
|
||||||
#define _IPersistFolder2_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblPersistFolder2)))
|
#define _IPersistFolder2_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblPersistFolder2)))
|
||||||
#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This =(class*)(((char*)name)-_IPersistFolder2_Offset);
|
#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
|
||||||
|
|
||||||
#define IShellExecuteHookW_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookW)))
|
#define IShellExecuteHookW_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookW)))
|
||||||
#define _ICOM_THIS_From_IShellExecuteHookW(class, name) class* This =(class*)(((char*)name)-IShellExecuteHookW_Offset);
|
#define _ICOM_THIS_From_IShellExecuteHookW(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookW_Offset);
|
||||||
|
|
||||||
#define IShellExecuteHookA_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookA)))
|
#define IShellExecuteHookA_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookA)))
|
||||||
#define _ICOM_THIS_From_IShellExecuteHookA(class, name) class* This =(class*)(((char*)name)-IShellExecuteHookA_Offset);
|
#define _ICOM_THIS_From_IShellExecuteHookA(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookA_Offset);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -381,19 +381,19 @@ ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface,
|
||||||
*ppvOut = NULL;
|
*ppvOut = NULL;
|
||||||
|
|
||||||
if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
|
if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
|
||||||
pObj =(LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
|
pObj = (LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
|
} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
|
||||||
pObj =(LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
|
pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
} else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
|
} else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
|
||||||
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
||||||
pObj =(LPUNKNOWN) IExtractIconA_Constructor(pidl);
|
pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
} else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
|
} else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
|
||||||
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
||||||
pObj =(LPUNKNOWN) IExtractIconW_Constructor(pidl);
|
pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
} else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
|
} else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
|
||||||
|
|
Loading…
Reference in a new issue