mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:42:57 +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)
|
if (!pidl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
hr = _SHGetPathFromIDListA(pidl, szTemp, MAX_PATH);
|
hr = SHELL_SHGetPathFromIDListA(pidl, szTemp, MAX_PATH);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -254,7 +254,7 @@ HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
hr = _SHGetPathFromIDListW(pidl, szTemp, MAX_PATH);
|
hr = SHELL_SHGetPathFromIDListW(pidl, szTemp, MAX_PATH);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return 0;
|
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;
|
LPSTR pstr = pszPath;
|
||||||
STRRET str;
|
|
||||||
LPSHELLFOLDER desktop;
|
|
||||||
LPSTR pstr;
|
|
||||||
LPSTR end = pszPath + uOutSize;
|
LPSTR end = pszPath + uOutSize;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
/* If the item ID list begins at "My Computer", we can use
|
/* One case is a PIDL rooted at desktop level */
|
||||||
an optimized loop to retrieve file system paths. */
|
if (_ILIsValue(pidl) || _ILIsFolder(pidl)) {
|
||||||
if (_ILIsMyComputer(pidl)) {
|
hr = SHGetSpecialFolderPathA(0, pstr, CSIDL_DESKTOP, FALSE);
|
||||||
LPCITEMIDLIST p = ILGetNext(pidl);
|
|
||||||
|
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;
|
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) {
|
txt = _ILGetTextPointer(pidl);
|
||||||
if (_ILIsSpecialFolder(p))
|
|
||||||
return E_INVALIDARG;
|
|
||||||
|
|
||||||
txt = _ILGetTextPointer(p);
|
|
||||||
if (!txt)
|
if (!txt)
|
||||||
break;
|
{hr = E_INVALIDARG; break;}
|
||||||
|
|
||||||
lstrcpynA(pstr, txt, end-pstr);
|
lstrcpynA(pstr, txt, end-pstr);
|
||||||
|
|
||||||
p = ILGetNext(p);
|
pidl = ILGetNext(pidl);
|
||||||
if (!p)
|
if (!pidl)
|
||||||
break;
|
{hr = E_INVALIDARG; break;}
|
||||||
|
|
||||||
if (!p->mkid.cb)
|
if (!pidl->mkid.cb) {
|
||||||
return TRUE;
|
/* We are at the end and successfully converted the complete PIDL. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pstr = PathAddBackslashA(pstr);
|
pstr = PathAddBackslashA(pstr);
|
||||||
if (!pstr)
|
if (!pstr)
|
||||||
break;
|
{hr = E_INVALIDARG; 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);
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return E_INVALIDARG;
|
hr = E_INVALIDARG;
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
TRACE_(shell)("-- %s, 0x%08lx\n", pszPath, S_OK);
|
||||||
hr = StrRetToStrNA(pstr, end-pstr, &str, pidl);
|
|
||||||
|
|
||||||
TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,78 +1364,63 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
hr = _SHGetPathFromIDListA(pidl, pszPath, MAX_PATH);
|
hr = SHELL_SHGetPathFromIDListA(pidl, pszPath, MAX_PATH);
|
||||||
|
|
||||||
return SUCCEEDED(hr);
|
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;
|
LPWSTR pstr = pszPath;
|
||||||
STRRET str;
|
|
||||||
LPSHELLFOLDER desktop;
|
|
||||||
LPWSTR pstr;
|
|
||||||
LPWSTR end = pszPath + uOutSize;
|
LPWSTR end = pszPath + uOutSize;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
/* If the item ID list begins at "My Computer", we can use
|
/* One case is a PIDL rooted at desktop level */
|
||||||
an optimized loop to retrieve file system paths. */
|
if (_ILIsValue(pidl) || _ILIsFolder(pidl)) {
|
||||||
if (_ILIsMyComputer(pidl)) {
|
hr = SHGetSpecialFolderPathW(0, pstr, CSIDL_DESKTOP, FALSE);
|
||||||
LPCITEMIDLIST p = ILGetNext(pidl);
|
|
||||||
|
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;
|
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) {
|
txt = _ILGetTextPointer(pidl);
|
||||||
if (_ILIsSpecialFolder(p))
|
|
||||||
return E_INVALIDARG;
|
|
||||||
|
|
||||||
txt = _ILGetTextPointer(p);
|
|
||||||
if (!txt)
|
if (!txt)
|
||||||
break;
|
{hr = E_INVALIDARG; break;}
|
||||||
|
|
||||||
if (!MultiByteToWideChar(CP_ACP, 0, txt, -1, pstr, uOutSize))
|
if (!MultiByteToWideChar(CP_ACP, 0, txt, -1, pstr, uOutSize))
|
||||||
break;
|
{hr = E_OUTOFMEMORY; break;}
|
||||||
|
|
||||||
p = ILGetNext(p);
|
pidl = ILGetNext(pidl);
|
||||||
if (!p)
|
if (!pidl)
|
||||||
break;
|
{hr = E_INVALIDARG; break;}
|
||||||
|
|
||||||
if (!p->mkid.cb)
|
if (!pidl->mkid.cb) {
|
||||||
return TRUE;
|
/* We are at the end and successfully converted the complete PIDL. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pstr = PathAddBackslashW(pstr);
|
pstr = PathAddBackslashW(pstr);
|
||||||
if (!pstr)
|
if (!pstr)
|
||||||
break;
|
{hr = E_INVALIDARG; 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);
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return E_INVALIDARG;
|
hr = E_INVALIDARG;
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
TRACE_(shell)("-- %s, 0x%08lx\n", debugstr_w(pszPath), hr);
|
||||||
hr = StrRetToStrNW(pstr, end-pstr, &str, pidl);
|
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)
|
if (!pidl)
|
||||||
return FALSE;
|
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);
|
TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
|
||||||
return SUCCEEDED(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 ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type);
|
||||||
BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);
|
BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);
|
||||||
|
|
||||||
HRESULT _SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize);
|
HRESULT SHELL_SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize);
|
||||||
HRESULT _SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize);
|
HRESULT SHELL_SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1311,7 +1311,7 @@ static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWOR
|
||||||
if (!This->sPath && This->pPidl) {
|
if (!This->sPath && This->pPidl) {
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
|
|
||||||
hr = _SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
hr = SHELL_SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||||
|
|
||||||
if (SUCCEEDED(hr) && *buffer) {
|
if (SUCCEEDED(hr) && *buffer) {
|
||||||
This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR));
|
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) {
|
if (!This->sPath && This->pPidl) {
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
|
|
||||||
hr = _SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
hr = SHELL_SHGetPathFromIDListW(This->pPidl, buffer, MAX_PATH);
|
||||||
|
|
||||||
if (SUCCEEDED(hr) && *buffer) {
|
if (SUCCEEDED(hr) && *buffer) {
|
||||||
This->sPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (lstrlenW(buffer)+1)*sizeof(WCHAR));
|
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 (SUCCEEDED(_ResolveShortCut(cmd, wdir, args, sei->hwnd, &sei->nShow, &tmpPidl))) {
|
||||||
if (!*cmd && tmpPidl) {
|
if (!*cmd && tmpPidl) {
|
||||||
/* We got a PIDL instead of a file system path. */
|
/* We got a PIDL instead of a file system path. */
|
||||||
IShellFolder* desktop;
|
if (SHGetPathFromIDListA(tmpPidl, cmd))
|
||||||
STRRET str;
|
tmpPidl = NULL;
|
||||||
|
|
||||||
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 (cmd[0]==':' && cmd[1]==':') {
|
if (cmd[0]==':' && cmd[1]==':') {
|
||||||
/* open shell folder for the specified class GUID */
|
/* open shell folder for the specified class GUID */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue