mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:35:59 +00:00
SHELL_SHGetPathFromIDList()
svn path=/trunk/; revision=7507
This commit is contained in:
parent
01c51c2aab
commit
22922dec07
5 changed files with 74 additions and 117 deletions
|
@ -222,7 +222,7 @@ HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|||
if (!pidl)
|
||||
return 0;
|
||||
|
||||
hr = _SHGetPathFromIDListA(pidl, szTemp, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListA(pidl, szTemp, MAX_PATH);
|
||||
SHFree(pidl);
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
|
@ -254,7 +254,7 @@ HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|||
if (!pidl)
|
||||
return 0;
|
||||
|
||||
hr = _SHGetPathFromIDListW(pidl, szTemp, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListW(pidl, szTemp, MAX_PATH);
|
||||
SHFree(pidl);
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
|
|
|
@ -1287,70 +1287,55 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
|
|||
}
|
||||
|
||||
/*************************************************************************
|
||||
* _SHGetPathFromIDListA
|
||||
* SHELL_SHGetPathFromIDListA
|
||||
*/
|
||||
HRESULT _SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize)
|
||||
HRESULT SHELL_SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize)
|
||||
{
|
||||
HRESULT hr;
|
||||
STRRET str;
|
||||
LPSHELLFOLDER desktop;
|
||||
LPSTR pstr;
|
||||
LPSTR pstr = pszPath;
|
||||
LPSTR end = pszPath + uOutSize;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
/* 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);
|
||||
/* One case is a PIDL rooted at desktop level */
|
||||
if (_ILIsValue(pidl) || _ILIsFolder(pidl)) {
|
||||
hr = SHGetSpecialFolderPathA(0, pstr, CSIDL_DESKTOP, FALSE);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
pstr = PathAddBackslashA(pstr);
|
||||
}
|
||||
/* The only other valid case is a item ID list beginning at "My Computer". */
|
||||
else if (_ILIsMyComputer(pidl))
|
||||
pidl = ILGetNext(pidl);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
LPSTR txt;
|
||||
|
||||
pstr = pszPath;
|
||||
while(pidl && pidl->mkid.cb && pstr<end) {
|
||||
if (_ILIsSpecialFolder(pidl))
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
while(p && p->mkid.cb && pstr<end) {
|
||||
if (_ILIsSpecialFolder(p))
|
||||
return E_INVALIDARG;
|
||||
|
||||
txt = _ILGetTextPointer(p);
|
||||
txt = _ILGetTextPointer(pidl);
|
||||
if (!txt)
|
||||
break;
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
lstrcpynA(pstr, txt, end-pstr);
|
||||
|
||||
p = ILGetNext(p);
|
||||
if (!p)
|
||||
break;
|
||||
pidl = ILGetNext(pidl);
|
||||
if (!pidl)
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
if (!p->mkid.cb)
|
||||
return TRUE;
|
||||
if (!pidl->mkid.cb) {
|
||||
/* We are at the end and successfully converted the complete PIDL. */
|
||||
break;
|
||||
}
|
||||
|
||||
pstr = PathAddBackslashA(pstr);
|
||||
if (!pstr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pstr = pszPath;
|
||||
|
||||
/* The only other valid case is a simple PIDL rooted at desktop level */
|
||||
if (_ILIsValue(pidl) && _ILIsPidlSimple(pidl)) {
|
||||
hr = SHGetDesktopFolder(&desktop);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = SHGetSpecialFolderPathA(0, pszPath, CSIDL_DESKTOP, FALSE);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
pstr = PathAddBackslashA(pszPath);
|
||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
||||
}
|
||||
|
||||
IShellFolder_Release(desktop);
|
||||
{hr = E_INVALIDARG; break;}
|
||||
}
|
||||
} else
|
||||
return E_INVALIDARG;
|
||||
hr = E_INVALIDARG;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = StrRetToStrNA(pstr, end-pstr, &str, pidl);
|
||||
|
||||
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
|
||||
TRACE_(shell)("-- %s, 0x%08lx\n", pszPath, S_OK);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -1379,78 +1364,63 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
|
|||
if (!pidl)
|
||||
return FALSE;
|
||||
|
||||
hr = _SHGetPathFromIDListA(pidl, pszPath, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListA(pidl, pszPath, MAX_PATH);
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* _SHGetPathFromIDListW
|
||||
* SHELL_SHGetPathFromIDListW
|
||||
*/
|
||||
HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
||||
HRESULT SHELL_SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
||||
{
|
||||
HRESULT hr;
|
||||
STRRET str;
|
||||
LPSHELLFOLDER desktop;
|
||||
LPWSTR pstr;
|
||||
LPWSTR pstr = pszPath;
|
||||
LPWSTR end = pszPath + uOutSize;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
/* 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);
|
||||
/* One case is a PIDL rooted at desktop level */
|
||||
if (_ILIsValue(pidl) || _ILIsFolder(pidl)) {
|
||||
hr = SHGetSpecialFolderPathW(0, pstr, CSIDL_DESKTOP, FALSE);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
pstr = PathAddBackslashW(pstr);
|
||||
}
|
||||
/* The only other valid case is a item ID list beginning at "My Computer". */
|
||||
else if (_ILIsMyComputer(pidl))
|
||||
pidl = ILGetNext(pidl);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
LPSTR txt;
|
||||
|
||||
pstr = pszPath;
|
||||
while(pidl && pidl->mkid.cb && pstr<end) {
|
||||
if (_ILIsSpecialFolder(pidl))
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
while(p && p->mkid.cb && pstr<end) {
|
||||
if (_ILIsSpecialFolder(p))
|
||||
return E_INVALIDARG;
|
||||
|
||||
txt = _ILGetTextPointer(p);
|
||||
txt = _ILGetTextPointer(pidl);
|
||||
if (!txt)
|
||||
break;
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, txt, -1, pstr, uOutSize))
|
||||
break;
|
||||
{hr = E_OUTOFMEMORY; break;}
|
||||
|
||||
p = ILGetNext(p);
|
||||
if (!p)
|
||||
break;
|
||||
pidl = ILGetNext(pidl);
|
||||
if (!pidl)
|
||||
{hr = E_INVALIDARG; break;}
|
||||
|
||||
if (!p->mkid.cb)
|
||||
return TRUE;
|
||||
if (!pidl->mkid.cb) {
|
||||
/* We are at the end and successfully converted the complete PIDL. */
|
||||
break;
|
||||
}
|
||||
|
||||
pstr = PathAddBackslashW(pstr);
|
||||
if (!pstr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pstr = pszPath;
|
||||
|
||||
/* The only other valid case is a simple PIDL rooted at desktop level */
|
||||
if (_ILIsValue(pidl) && _ILIsPidlSimple(pidl)) {
|
||||
hr = SHGetDesktopFolder(&desktop);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
pstr = PathAddBackslashW(pszPath);
|
||||
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &str);
|
||||
}
|
||||
|
||||
IShellFolder_Release(desktop);
|
||||
{hr = E_INVALIDARG; break;}
|
||||
}
|
||||
} else
|
||||
return E_INVALIDARG;
|
||||
hr = E_INVALIDARG;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = StrRetToStrNW(pstr, end-pstr, &str, pidl);
|
||||
|
||||
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
|
||||
return hr;
|
||||
TRACE_(shell)("-- %s, 0x%08lx\n", debugstr_w(pszPath), hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -1466,7 +1436,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
|
|||
if (!pidl)
|
||||
return FALSE;
|
||||
|
||||
hr = _SHGetPathFromIDListW(pidl, pszPath, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListW(pidl, pszPath, MAX_PATH);
|
||||
|
||||
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
|
||||
return SUCCEEDED(hr);
|
||||
|
|
|
@ -223,7 +223,7 @@ LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida);
|
|||
BOOL WINAPI ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type);
|
||||
BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);
|
||||
|
||||
HRESULT _SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize);
|
||||
HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize);
|
||||
HRESULT SHELL_SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize);
|
||||
HRESULT SHELL_SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1311,7 +1311,7 @@ static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWOR
|
|||
if (!This->sPath && This->pPidl) {
|
||||
WCHAR buffer[MAX_PATH];
|
||||
|
||||
hr = _SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||
|
||||
if (SUCCEEDED(hr) && *buffer) {
|
||||
This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR));
|
||||
|
@ -1740,7 +1740,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR
|
|||
if (!This->sPath && This->pPidl) {
|
||||
WCHAR buffer[MAX_PATH];
|
||||
|
||||
hr = _SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||
hr = SHELL_SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||
|
||||
if (SUCCEEDED(hr) && *buffer) {
|
||||
This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR));
|
||||
|
|
|
@ -922,21 +922,8 @@ BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execf
|
|||
if (SUCCEEDED(_ResolveShortCut(cmd, wdir, args, sei->hwnd, &sei->nShow, &tmpPidl))) {
|
||||
if (!*cmd && tmpPidl) {
|
||||
/* We got a PIDL instead of a file system path. */
|
||||
IShellFolder* desktop;
|
||||
STRRET str;
|
||||
|
||||
HRESULT hr = SHGetDesktopFolder(&desktop);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = IShellFolder_GetDisplayNameOf(desktop, tmpPidl, SHGDN_FORPARSING, &str);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = StrRetToStrNW(cmd, MAX_PATH, &str, tmpPidl);
|
||||
tmpPidl = NULL;
|
||||
}
|
||||
|
||||
IShellFolder_Release(desktop);
|
||||
}
|
||||
if (SHGetPathFromIDListA(tmpPidl, cmd))
|
||||
tmpPidl = NULL;
|
||||
|
||||
if (cmd[0]==':' && cmd[1]==':') {
|
||||
/* open shell folder for the specified class GUID */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue