[SHELL32] Implement CSIDL_CONNECTIONS and fix CSIDL_PRINTERS (#6919)

This commit is contained in:
Whindmar Saksit 2024-05-21 21:09:18 +02:00 committed by GitHub
parent a549a9d8e4
commit a25a4eb7b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 0 deletions

View file

@ -181,6 +181,7 @@ Shell_DisplayNameOf(
_Out_ LPWSTR pszBuf, _Out_ LPWSTR pszBuf,
_In_ UINT cchBuf); _In_ UINT cchBuf);
EXTERN_C
HRESULT SHBindToObject( HRESULT SHBindToObject(
_In_opt_ IShellFolder *psf, _In_opt_ IShellFolder *psf,
_In_ LPCITEMIDLIST pidl, _In_ LPCITEMIDLIST pidl,

View file

@ -202,6 +202,7 @@ SHBindToObjectEx(
return hr; return hr;
} }
EXTERN_C
HRESULT SHBindToObject( HRESULT SHBindToObject(
_In_opt_ IShellFolder *psf, _In_opt_ IShellFolder *psf,
_In_ LPCITEMIDLIST pidl, _In_ LPCITEMIDLIST pidl,

View file

@ -1680,6 +1680,13 @@ LPITEMIDLIST _ILCreateControlPanel(void)
LPITEMIDLIST _ILCreatePrinters(void) LPITEMIDLIST _ILCreatePrinters(void)
{ {
#ifdef __REACTOS__
// Note: Wine returns the PIDL as it was in Windows 95, NT5 moved it into CSIDL_CONTROLS
extern HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEMIDLIST *ppidl);
LPITEMIDLIST pidl;
SHGetFolderLocationHelper(NULL, CSIDL_CONTROLS, &CLSID_Printers, &pidl);
return pidl;
#else
LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL; LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
TRACE("()\n"); TRACE("()\n");
@ -1695,6 +1702,7 @@ LPITEMIDLIST _ILCreatePrinters(void)
SHFree(parent); SHFree(parent);
} }
return ret; return ret;
#endif
} }
LPITEMIDLIST _ILCreateNetwork(void) LPITEMIDLIST _ILCreateNetwork(void)

View file

@ -3099,6 +3099,32 @@ BOOL WINAPI SHGetSpecialFolderPathW (
szPath) == S_OK; szPath) == S_OK;
} }
#ifdef __REACTOS__
HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEMIDLIST *ppidl)
{
HRESULT hr;
IShellFolder *psf;
LPITEMIDLIST parent, child;
EXTERN_C HRESULT SHBindToObject(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppvObj);
*ppidl = NULL;
if (FAILED(hr = SHGetFolderLocation(hwnd, nFolder, NULL, 0, &parent)))
return hr;
if (SUCCEEDED(hr = SHBindToObject(NULL, parent, &IID_IShellFolder, (void**)&psf)))
{
WCHAR clsidstr[2 + 38 + 1];
clsidstr[0] = clsidstr[1] = L':';
StringFromGUID2(clsid, clsidstr + 2, 38 + 1);
hr = IShellFolder_ParseDisplayName(psf, hwnd, NULL, clsidstr, NULL, &child, NULL);
if (SUCCEEDED(hr))
*ppidl = ILCombine(parent, child);
IShellFolder_Release(psf);
ILFree(child);
}
ILFree(parent);
return hr;
}
#endif
/************************************************************************* /*************************************************************************
* SHGetFolderLocation [SHELL32.@] * SHGetFolderLocation [SHELL32.@]
* *
@ -3186,6 +3212,15 @@ HRESULT WINAPI SHGetFolderLocation(
*ppidl = _ILCreateNetwork(); *ppidl = _ILCreateNetwork();
break; break;
#ifdef __REACTOS__
case CSIDL_CONNECTIONS:
{
EXTERN_C const CLSID CLSID_ConnectionFolder;
hr = SHGetFolderLocationHelper(hwndOwner, CSIDL_CONTROLS, &CLSID_ConnectionFolder, ppidl);
break;
}
#endif
default: default:
{ {
WCHAR szPath[MAX_PATH]; WCHAR szPath[MAX_PATH];