2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
/*
|
2005-02-21 19:36:47 +01:00
|
|
|
* Virtual Desktop Folder
|
2002-07-24 03:56:03 +02:00
|
|
|
*
|
2005-02-21 19:36:47 +01:00
|
|
|
* Copyright 1997 Marcus Meissner
|
|
|
|
* Copyright 1998, 1999, 2002 Juergen Schmied
|
2002-07-24 03:56:03 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-07-24 03:56:03 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-07-24 03:56:03 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-07-24 03:56:03 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "ole2.h"
|
2002-07-24 03:56:03 +02:00
|
|
|
#include "shlguid.h"
|
|
|
|
|
|
|
|
#include "pidl.h"
|
|
|
|
#include "undocshell.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "shresdef.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "shellfolder.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "debughlp.h"
|
|
|
|
#include "shfldr.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL (shell);
|
|
|
|
|
2009-01-28 17:32:38 +01:00
|
|
|
/* Undocumented functions from shdocvw */
|
|
|
|
extern HRESULT WINAPI IEParseDisplayNameWithBCW(DWORD codepage, LPCWSTR lpszDisplayName, LPBC pbc, LPITEMIDLIST *ppidl);
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
/***********************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* Desktopfolder implementation
|
2002-07-24 03:56:03 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
2010-12-04 22:21:57 +01:00
|
|
|
IShellFolder2 IShellFolder2_iface;
|
|
|
|
IPersistFolder2 IPersistFolder2_iface;
|
2005-07-03 14:03:35 +02:00
|
|
|
LONG ref;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
/* both paths are parsible from the desktop */
|
2005-03-17 14:57:38 +01:00
|
|
|
LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
|
|
|
|
LPITEMIDLIST pidlRoot; /* absolute pidl */
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
UINT cfShellIDList; /* clipboardformat for IDropTarget */
|
|
|
|
BOOL fAcceptFmt; /* flag for pending Drop */
|
2010-03-29 23:30:37 +02:00
|
|
|
} IDesktopFolderImpl;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2014-06-14 21:56:45 +02:00
|
|
|
static IDesktopFolderImpl *cached_sf;
|
|
|
|
|
2010-12-04 22:21:57 +01:00
|
|
|
static inline IDesktopFolderImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDesktopFolderImpl, IShellFolder2_iface);
|
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
static inline IDesktopFolderImpl *impl_from_IPersistFolder2( IPersistFolder2 *iface )
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
return CONTAINING_RECORD(iface, IDesktopFolderImpl, IPersistFolder2_iface);
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
|
|
|
|
2017-09-25 09:59:36 +02:00
|
|
|
static const shvheader desktop_header[] =
|
|
|
|
{
|
|
|
|
{ &FMTID_Storage, PID_STG_NAME, IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
|
|
|
|
{ &FMTID_Storage, PID_STG_SIZE, IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
|
|
|
|
{ &FMTID_Storage, PID_STG_STORAGETYPE, IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
|
|
|
|
{ &FMTID_Storage, PID_STG_WRITETIME, IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12 },
|
|
|
|
{ &FMTID_Storage, PID_STG_ATTRIBUTES, IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 },
|
2002-07-24 03:56:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnQueryInterface
|
2002-07-24 03:56:03 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-02-21 19:36:47 +01:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnQueryInterface(
|
|
|
|
IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
|
|
|
|
|
2015-06-27 12:40:11 +02:00
|
|
|
if (!ppvObj) return E_POINTER;
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
*ppvObj = NULL;
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID (riid, &IID_IShellFolder) ||
|
|
|
|
IsEqualIID (riid, &IID_IShellFolder2))
|
|
|
|
{
|
2013-09-04 08:12:30 +02:00
|
|
|
*ppvObj = &This->IShellFolder2_iface;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2010-07-18 14:34:56 +02:00
|
|
|
else if (IsEqualIID (riid, &IID_IPersist) ||
|
|
|
|
IsEqualIID (riid, &IID_IPersistFolder) ||
|
|
|
|
IsEqualIID (riid, &IID_IPersistFolder2))
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
*ppvObj = &This->IPersistFolder2_iface;
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if (*ppvObj)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef ((IUnknown *) (*ppvObj));
|
|
|
|
TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
|
|
|
|
return S_OK;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
TRACE ("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
|
|
|
|
{
|
2007-06-21 16:50:55 +02:00
|
|
|
return 2; /* non-heap based object */
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
|
|
|
|
{
|
2007-06-21 16:50:55 +02:00
|
|
|
return 1; /* non-heap based object */
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnParseDisplayName
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
|
|
|
|
* to MyComputer
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
|
|
|
|
DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
WCHAR szElement[MAX_PATH];
|
|
|
|
LPCWSTR szNext = NULL;
|
|
|
|
LPITEMIDLIST pidlTemp = NULL;
|
2010-06-28 19:06:24 +02:00
|
|
|
PARSEDURLW urldata;
|
2004-04-15 01:57:46 +02:00
|
|
|
HRESULT hr = S_OK;
|
2002-07-24 03:56:03 +02:00
|
|
|
CLSID clsid;
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
|
2005-02-21 19:36:47 +01:00
|
|
|
This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName),
|
|
|
|
pchEaten, ppidl, pdwAttributes);
|
2003-09-16 00:16:41 +02:00
|
|
|
|
2010-03-03 02:56:20 +01:00
|
|
|
if (!ppidl) return E_INVALIDARG;
|
2002-07-24 03:56:03 +02:00
|
|
|
*ppidl = 0;
|
2003-09-16 00:16:41 +02:00
|
|
|
|
2010-03-03 02:56:20 +01:00
|
|
|
if (!lpszDisplayName) return E_INVALIDARG;
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
if (pchEaten)
|
2005-02-21 19:36:47 +01:00
|
|
|
*pchEaten = 0; /* strange but like the original */
|
|
|
|
|
2010-06-28 19:06:24 +02:00
|
|
|
urldata.cbSize = sizeof(urldata);
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':')
|
|
|
|
{
|
|
|
|
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
|
|
|
|
TRACE ("-- element: %s\n", debugstr_w (szElement));
|
|
|
|
SHCLSIDFromStringW (szElement + 2, &clsid);
|
|
|
|
pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
|
|
|
|
}
|
|
|
|
else if (PathGetDriveNumberW (lpszDisplayName) >= 0)
|
|
|
|
{
|
2005-06-29 13:17:33 +02:00
|
|
|
/* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
|
2021-09-15 09:55:32 +02:00
|
|
|
pidlTemp = _ILCreateMyComputer ();
|
|
|
|
szNext = lpszDisplayName;
|
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsncmp( lpszDisplayName, L"\\\\?\\unix\\", 9 ))
|
2021-09-15 09:55:32 +02:00
|
|
|
{
|
|
|
|
pidlTemp = _ILCreateGuid(PT_GUID, &CLSID_UnixDosFolder);
|
2005-02-21 19:36:47 +01:00
|
|
|
szNext = lpszDisplayName;
|
|
|
|
}
|
|
|
|
else if (PathIsUNCW(lpszDisplayName))
|
|
|
|
{
|
|
|
|
pidlTemp = _ILCreateNetwork();
|
|
|
|
szNext = lpszDisplayName;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2005-02-23 13:45:12 +01:00
|
|
|
else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) )
|
|
|
|
{
|
|
|
|
*ppidl = pidlTemp;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-06-28 19:06:24 +02:00
|
|
|
else if (SUCCEEDED(ParseURLW(lpszDisplayName, &urldata)))
|
2009-01-28 17:32:38 +01:00
|
|
|
{
|
2009-06-26 10:01:08 +02:00
|
|
|
if (urldata.nScheme == URL_SCHEME_SHELL) /* handle shell: urls */
|
|
|
|
{
|
|
|
|
TRACE ("-- shell url: %s\n", debugstr_w(urldata.pszSuffix));
|
|
|
|
SHCLSIDFromStringW (urldata.pszSuffix+2, &clsid);
|
|
|
|
pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return IEParseDisplayNameWithBCW(CP_ACP,lpszDisplayName,pbc,ppidl);
|
2009-01-28 17:32:38 +01:00
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* it's a filesystem path on the desktop. Let a FSFolder parse it */
|
|
|
|
|
|
|
|
if (*lpszDisplayName)
|
|
|
|
{
|
2010-06-28 19:06:27 +02:00
|
|
|
if (*lpszDisplayName == '/')
|
2005-03-02 11:16:41 +01:00
|
|
|
{
|
2010-06-28 19:06:27 +02:00
|
|
|
/* UNIX paths should be parsed by unixfs */
|
|
|
|
IShellFolder *unixFS;
|
|
|
|
hr = UnixFolder_Constructor(NULL, &IID_IShellFolder, (LPVOID*)&unixFS);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_ParseDisplayName(unixFS, NULL, NULL,
|
|
|
|
lpszDisplayName, NULL, &pidlTemp, NULL);
|
|
|
|
IShellFolder_Release(unixFS);
|
|
|
|
}
|
2005-03-02 11:16:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-28 19:06:27 +02:00
|
|
|
/* build a complete path to create a simple pidl */
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
LPWSTR pathPtr;
|
|
|
|
|
|
|
|
lstrcpynW(szPath, This->sPathTarget, MAX_PATH);
|
|
|
|
pathPtr = PathAddBackslashW(szPath);
|
|
|
|
if (pathPtr)
|
|
|
|
{
|
|
|
|
lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath));
|
|
|
|
hr = _ILCreateFromPathW(szPath, &pidlTemp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* should never reach here, but for completeness */
|
2014-10-08 06:31:10 +02:00
|
|
|
hr = E_NOT_SUFFICIENT_BUFFER;
|
2010-06-28 19:06:27 +02:00
|
|
|
}
|
2005-03-02 11:16:41 +01:00
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pidlTemp = _ILCreateMyComputer();
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
szNext = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && pidlTemp)
|
|
|
|
{
|
|
|
|
if (szNext && *szNext)
|
|
|
|
{
|
|
|
|
hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc,
|
|
|
|
&pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pdwAttributes && *pdwAttributes)
|
2016-11-27 15:01:48 +01:00
|
|
|
hr = SHELL32_GetItemAttributes(iface, pidlTemp, pdwAttributes);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppidl = pidlTemp;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-11-30 00:39:38 +01:00
|
|
|
static void add_shell_namespace_extensions(IEnumIDListImpl *list, HKEY root)
|
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
WCHAR guid[39], clsidkeyW[60];
|
2016-11-30 00:39:38 +01:00
|
|
|
DWORD size, i = 0;
|
|
|
|
HKEY hkey;
|
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
if (RegOpenKeyExW(root, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace", 0, KEY_READ, &hkey))
|
2016-11-30 00:39:38 +01:00
|
|
|
return;
|
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
size = ARRAY_SIZE(guid);
|
2016-11-30 00:39:38 +01:00
|
|
|
while (!RegEnumKeyExW(hkey, i++, guid, &size, 0, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
DWORD attributes, value_size = sizeof(attributes);
|
|
|
|
|
|
|
|
/* Check if extension is configured as nonenumerable */
|
2021-09-20 12:58:52 +02:00
|
|
|
swprintf(clsidkeyW, ARRAY_SIZE(clsidkeyW), L"CLSID\\%s\\ShellFolder", guid);
|
|
|
|
RegGetValueW(HKEY_CLASSES_ROOT, clsidkeyW, L"Attributes", RRF_RT_REG_DWORD | RRF_ZEROONFAILURE,
|
2016-11-30 00:39:38 +01:00
|
|
|
NULL, &attributes, &value_size);
|
|
|
|
|
|
|
|
if (!(attributes & SFGAO_NONENUMERATED))
|
|
|
|
AddToEnumList(list, _ILCreateGuidFromStrW(guid));
|
2018-03-19 08:11:27 +01:00
|
|
|
size = ARRAY_SIZE(guid);
|
2016-11-30 00:39:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2004-04-08 21:50:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* CreateDesktopEnumList()
|
|
|
|
*/
|
2011-10-10 01:04:37 +02:00
|
|
|
static BOOL CreateDesktopEnumList(IEnumIDListImpl *list, DWORD dwFlags)
|
2004-04-08 21:50:17 +02:00
|
|
|
{
|
|
|
|
BOOL ret = TRUE;
|
2005-02-23 13:45:12 +01:00
|
|
|
WCHAR szPath[MAX_PATH];
|
2004-04-08 21:50:17 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
|
2004-04-08 21:50:17 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
/* enumerate the root folders */
|
|
|
|
if (dwFlags & SHCONTF_FOLDERS)
|
2004-04-08 21:50:17 +02:00
|
|
|
{
|
|
|
|
ret = AddToEnumList(list, _ILCreateMyComputer());
|
2016-11-30 00:39:38 +01:00
|
|
|
add_shell_namespace_extensions(list, HKEY_LOCAL_MACHINE);
|
|
|
|
add_shell_namespace_extensions(list, HKEY_CURRENT_USER);
|
2004-04-08 21:50:17 +02:00
|
|
|
}
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
/* enumerate the elements in %windir%\desktop */
|
2012-10-03 15:51:15 +02:00
|
|
|
ret = ret && SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
|
2004-04-08 21:50:17 +02:00
|
|
|
ret = ret && CreateFolderEnumList(list, szPath, dwFlags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnEnumObjects
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2011-10-10 01:02:48 +02:00
|
|
|
IEnumIDListImpl *list;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
|
2005-02-21 19:36:47 +01:00
|
|
|
This, hwndOwner, dwFlags, ppEnumIDList);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2011-10-10 01:02:48 +02:00
|
|
|
if (!(list = IEnumIDList_Constructor()))
|
|
|
|
return E_OUTOFMEMORY;
|
2011-10-10 01:04:37 +02:00
|
|
|
CreateDesktopEnumList(list, dwFlags);
|
2011-10-10 01:02:48 +02:00
|
|
|
*ppEnumIDList = &list->IEnumIDList_iface;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
|
|
|
|
|
2011-10-10 01:02:48 +02:00
|
|
|
return S_OK;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnBindToObject
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
|
|
|
|
This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2021-09-15 09:53:56 +02:00
|
|
|
return SHELL32_BindToChild( This->pidlRoot, &CLSID_ShellFSFolder, This->sPathTarget, pidl, riid, ppvOut );
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnBindToStorage
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
|
|
|
|
This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnCompareIDs
|
|
|
|
*/
|
2010-03-29 23:30:37 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 *iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2010-03-29 23:30:37 +02:00
|
|
|
HRESULT hr;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
|
2013-02-25 23:46:57 +01:00
|
|
|
hr = SHELL32_CompareIDs(iface, lParam, pidl1, pidl2);
|
2010-03-29 23:30:37 +02:00
|
|
|
TRACE ("-- 0x%08x\n", hr);
|
|
|
|
return hr;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnCreateViewObject
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
LPSHELLVIEW pShellView;
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
|
|
|
|
This, hwndOwner, shdebugstr_guid (riid), ppvOut);
|
|
|
|
|
|
|
|
if (!ppvOut)
|
2010-03-29 23:30:37 +02:00
|
|
|
return E_INVALIDARG;
|
2005-02-21 19:36:47 +01:00
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IDropTarget))
|
|
|
|
{
|
|
|
|
WARN ("IDropTarget not implemented\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, &IID_IContextMenu))
|
|
|
|
{
|
2021-05-03 03:12:07 +02:00
|
|
|
hr = BackgroundMenu_Constructor((IShellFolder*)iface, TRUE, riid, ppvOut);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, &IID_IShellView))
|
|
|
|
{
|
|
|
|
pShellView = IShellView_Constructor ((IShellFolder *) iface);
|
|
|
|
if (pShellView)
|
|
|
|
{
|
|
|
|
hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
|
|
|
|
IShellView_Release (pShellView);
|
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnGetAttributesOf
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2010-03-29 23:30:37 +02:00
|
|
|
|
2005-10-06 13:38:45 +02:00
|
|
|
static const DWORD dwDesktopAttributes =
|
2005-08-11 12:33:21 +02:00
|
|
|
SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR |
|
2005-06-14 20:10:24 +02:00
|
|
|
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
|
2005-11-28 10:38:06 +01:00
|
|
|
static const DWORD dwMyComputerAttributes =
|
|
|
|
SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET |
|
|
|
|
SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
|
2005-05-10 10:28:11 +02:00
|
|
|
This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-05-10 10:28:11 +02:00
|
|
|
if (!rgfInOut)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (cidl && !apidl)
|
2005-02-21 19:36:47 +01:00
|
|
|
return E_INVALIDARG;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2004-04-13 02:19:11 +02:00
|
|
|
if (*rgfInOut == 0)
|
2005-02-21 19:36:47 +01:00
|
|
|
*rgfInOut = ~0;
|
2005-05-26 18:09:12 +02:00
|
|
|
|
|
|
|
if(cidl == 0) {
|
2005-06-14 20:10:24 +02:00
|
|
|
*rgfInOut &= dwDesktopAttributes;
|
2005-05-26 18:09:12 +02:00
|
|
|
} else {
|
|
|
|
while (cidl > 0 && *apidl) {
|
|
|
|
pdump (*apidl);
|
2005-06-14 20:10:24 +02:00
|
|
|
if (_ILIsDesktop(*apidl)) {
|
|
|
|
*rgfInOut &= dwDesktopAttributes;
|
2005-11-28 10:38:06 +01:00
|
|
|
} else if (_ILIsMyComputer(*apidl)) {
|
|
|
|
*rgfInOut &= dwMyComputerAttributes;
|
2005-06-14 20:10:24 +02:00
|
|
|
} else {
|
2016-11-27 15:01:48 +01:00
|
|
|
SHELL32_GetItemAttributes(iface, *apidl, rgfInOut);
|
2005-06-14 20:10:24 +02:00
|
|
|
}
|
2005-05-26 18:09:12 +02:00
|
|
|
apidl++;
|
|
|
|
cidl--;
|
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2005-05-10 10:28:11 +02:00
|
|
|
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
|
|
|
|
*rgfInOut &= ~SFGAO_VALIDATE;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("-- result=0x%08x\n", *rgfInOut);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2010-03-29 23:30:37 +02:00
|
|
|
return S_OK;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnGetUIObjectOf
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* HWND hwndOwner, //[in ] Parent window for any output
|
|
|
|
* UINT cidl, //[in ] array size
|
|
|
|
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
|
|
|
|
* REFIID riid, //[in ] Requested Interface
|
|
|
|
* UINT* prgfInOut, //[ ] reserved
|
|
|
|
* LPVOID* ppvObject) //[out] Resulting Interface
|
|
|
|
*
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl,
|
|
|
|
REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
IUnknown *pObj = NULL;
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
|
2005-02-21 19:36:47 +01:00
|
|
|
This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
|
|
|
|
|
|
|
|
if (!ppvOut)
|
2010-03-29 23:30:37 +02:00
|
|
|
return E_INVALIDARG;
|
2005-02-21 19:36:47 +01:00
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IContextMenu))
|
|
|
|
{
|
2005-03-14 11:49:03 +01:00
|
|
|
if (cidl > 0)
|
2012-01-11 03:02:03 +01:00
|
|
|
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
|
2005-03-14 11:49:03 +01:00
|
|
|
else
|
2012-01-11 02:39:24 +01:00
|
|
|
return BackgroundMenu_Constructor((IShellFolder*)iface, TRUE, riid, ppvOut);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
|
|
|
|
{
|
|
|
|
pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner,
|
|
|
|
This->pidlRoot, apidl, cidl);
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
|
|
|
|
{
|
|
|
|
pidl = ILCombine (This->pidlRoot, apidl[0]);
|
|
|
|
pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
|
|
|
|
SHFree (pidl);
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
|
|
|
|
{
|
|
|
|
pidl = ILCombine (This->pidlRoot, apidl[0]);
|
|
|
|
pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
|
|
|
|
SHFree (pidl);
|
|
|
|
hr = S_OK;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
|
|
|
|
{
|
2012-07-29 10:51:05 +02:00
|
|
|
hr = IShellFolder2_QueryInterface (iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
&IID_IDropTarget, (LPVOID *) & pObj);
|
|
|
|
}
|
|
|
|
else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
|
|
|
|
IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1))
|
|
|
|
{
|
|
|
|
pidl = ILCombine (This->pidlRoot, apidl[0]);
|
2013-08-16 09:36:42 +02:00
|
|
|
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, &pObj);
|
2005-02-21 19:36:47 +01:00
|
|
|
SHFree (pidl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_NOINTERFACE;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && !pObj)
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*ppvOut = pObj;
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("(%p)->hr=0x%08x\n", This, hr);
|
2002-07-24 03:56:03 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnGetDisplayNameOf
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* special case: pidl = null gives desktop-name back
|
|
|
|
*/
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
HRESULT hr = S_OK;
|
2007-04-10 11:20:48 +02:00
|
|
|
LPWSTR pszPath;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
|
2002-07-24 03:56:03 +02:00
|
|
|
pdump (pidl);
|
|
|
|
|
|
|
|
if (!strRet)
|
2005-02-21 19:36:47 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2007-04-10 11:20:48 +02:00
|
|
|
pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
|
|
|
|
if (!pszPath)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if (_ILIsDesktop (pidl))
|
|
|
|
{
|
|
|
|
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
|
2005-05-23 18:31:42 +02:00
|
|
|
(GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
|
2021-09-17 17:16:11 +02:00
|
|
|
lstrcpyW(pszPath, This->sPathTarget);
|
2005-02-21 19:36:47 +01:00
|
|
|
else
|
2007-04-10 11:20:48 +02:00
|
|
|
HCR_GetClassNameW(&CLSID_ShellDesktop, pszPath, MAX_PATH);
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
else if (_ILIsPidlSimple (pidl))
|
|
|
|
{
|
2005-04-12 12:15:29 +02:00
|
|
|
GUID const *clsid;
|
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if ((clsid = _ILGetGUIDPointer (pidl)))
|
|
|
|
{
|
2019-01-23 16:27:14 +01:00
|
|
|
if ((GET_SHGDN_FOR (dwFlags) & (SHGDN_FORPARSING | SHGDN_FORADDRESSBAR)) == SHGDN_FORPARSING)
|
2005-02-21 19:36:47 +01:00
|
|
|
{
|
2013-11-12 01:16:39 +01:00
|
|
|
BOOL bWantsForParsing;
|
2005-02-21 19:36:47 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We can only get a filesystem path from a shellfolder if the
|
|
|
|
* value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
|
|
|
|
*
|
|
|
|
* Exception: The MyComputer folder doesn't have this key,
|
|
|
|
* but any other filesystem backed folder it needs it.
|
|
|
|
*/
|
|
|
|
if (IsEqualIID (clsid, &CLSID_MyComputer))
|
|
|
|
{
|
2005-04-12 12:15:29 +02:00
|
|
|
bWantsForParsing = TRUE;
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* get the "WantsFORPARSING" flag from the registry */
|
2005-03-02 11:16:41 +01:00
|
|
|
WCHAR szRegPath[100];
|
2005-02-21 19:36:47 +01:00
|
|
|
LONG r;
|
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
lstrcpyW (szRegPath, L"CLSID\\");
|
2005-03-02 11:16:41 +01:00
|
|
|
SHELL32_GUIDToStringW (clsid, &szRegPath[6]);
|
2021-09-20 12:58:52 +02:00
|
|
|
lstrcatW (szRegPath, L"\\shellfolder");
|
|
|
|
r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath, L"WantsForParsing", NULL, NULL, NULL);
|
2005-02-21 19:36:47 +01:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
bWantsForParsing = TRUE;
|
|
|
|
else
|
|
|
|
bWantsForParsing = FALSE;
|
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
|
|
|
|
bWantsForParsing)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* we need the filesystem path to the destination folder.
|
|
|
|
* Only the folder itself can know it
|
|
|
|
*/
|
|
|
|
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
|
2007-04-10 11:20:48 +02:00
|
|
|
pszPath,
|
2005-04-12 12:15:29 +02:00
|
|
|
MAX_PATH);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* parsing name like ::{...} */
|
2007-04-10 11:20:48 +02:00
|
|
|
pszPath[0] = ':';
|
|
|
|
pszPath[1] = ':';
|
|
|
|
SHELL32_GUIDToStringW (clsid, &pszPath[2]);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* user friendly name */
|
2007-04-10 11:20:48 +02:00
|
|
|
HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-15 11:41:58 +02:00
|
|
|
int cLen = 0;
|
2006-01-16 21:31:48 +01:00
|
|
|
|
2005-08-15 11:41:58 +02:00
|
|
|
/* file system folder or file rooted at the desktop */
|
|
|
|
if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
|
|
|
|
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
|
|
|
|
{
|
2007-04-10 11:20:48 +02:00
|
|
|
lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1);
|
|
|
|
PathAddBackslashW(pszPath);
|
|
|
|
cLen = lstrlenW(pszPath);
|
2005-08-15 11:41:58 +02:00
|
|
|
}
|
2006-01-16 21:31:48 +01:00
|
|
|
|
2007-04-10 11:20:48 +02:00
|
|
|
_ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen);
|
2005-02-21 19:36:47 +01:00
|
|
|
|
|
|
|
if (!_ILIsFolder(pidl))
|
2007-04-10 11:20:48 +02:00
|
|
|
SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
|
2005-02-21 19:36:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* a complex pidl, let the subfolder do the work */
|
2005-04-12 12:15:29 +02:00
|
|
|
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
|
2007-04-10 11:20:48 +02:00
|
|
|
pszPath, MAX_PATH);
|
2006-06-19 21:27:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2007-04-10 11:20:48 +02:00
|
|
|
/* Win9x always returns ANSI strings, NT always returns Unicode strings */
|
|
|
|
if (GetVersion() & 0x80000000)
|
2006-01-16 21:31:10 +01:00
|
|
|
{
|
2007-04-10 11:20:48 +02:00
|
|
|
strRet->uType = STRRET_CSTR;
|
|
|
|
if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
|
|
|
|
NULL, NULL))
|
|
|
|
strRet->u.cStr[0] = '\0';
|
|
|
|
CoTaskMemFree(pszPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strRet->uType = STRRET_WSTR;
|
|
|
|
strRet->u.pOleStr = pszPath;
|
2006-01-16 21:31:10 +01:00
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2007-04-10 11:20:48 +02:00
|
|
|
else
|
|
|
|
CoTaskMemFree(pszPath);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE ("-- (%p)->(%s,0x%08x)\n", This,
|
2010-03-29 23:30:37 +02:00
|
|
|
strRet->uType == STRRET_CSTR ? strRet->u.cStr :
|
|
|
|
debugstr_w(strRet->u.pOleStr), hr);
|
2002-07-24 03:56:03 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-21 19:36:47 +01:00
|
|
|
* ISF_Desktop_fnSetNameOf
|
|
|
|
* Changes the name of a file object or subfolder, possibly changing its item
|
|
|
|
* identifier in the process.
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* HWND hwndOwner, //[in ] Owner window for output
|
|
|
|
* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
|
|
|
|
* LPCOLESTR lpszName, //[in ] the items new display name
|
|
|
|
* DWORD dwFlags, //[in ] SHGNO formatting flags
|
|
|
|
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface,
|
|
|
|
HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */
|
|
|
|
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2010-03-29 23:30:37 +02:00
|
|
|
FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This, hwndOwner, pidl,
|
2005-02-21 19:36:47 +01:00
|
|
|
debugstr_w (lpName), dwFlags, pPidlOut);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2017-09-27 10:13:43 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2 *iface, GUID *guid)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2017-09-27 10:13:43 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, guid);
|
2002-07-24 03:56:03 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 *iface,
|
|
|
|
IEnumExtraSearch ** ppenum)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2010-03-29 23:30:37 +02:00
|
|
|
FIXME ("(%p)->(%p) stub\n", This, ppenum);
|
2002-07-24 03:56:03 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
|
2017-09-27 10:13:42 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn(IShellFolder2 *iface, DWORD reserved, ULONG *sort, ULONG *display)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2017-09-27 10:13:42 +02:00
|
|
|
TRACE ("(%p)->(%#x, %p, %p)\n", This, reserved, sort, display);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2017-09-27 10:13:42 +02:00
|
|
|
return E_NOTIMPL;
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2017-09-27 10:13:42 +02:00
|
|
|
|
2005-02-21 19:36:47 +01:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (
|
|
|
|
IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2010-03-29 23:30:37 +02:00
|
|
|
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
if (!pcsFlags || iColumn >= ARRAY_SIZE(desktop_header))
|
|
|
|
return E_INVALIDARG;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2010-04-18 16:04:25 +02:00
|
|
|
*pcsFlags = desktop_header[iColumn].pcsFlags;
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2010-03-29 23:30:37 +02:00
|
|
|
FIXME ("(%p)->(%p %p %p) stub\n", This, pidl, pscid, pv);
|
2002-07-24 03:56:03 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
|
2005-02-21 19:36:47 +01:00
|
|
|
LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
|
|
|
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
|
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
if (!psd || iColumn >= ARRAY_SIZE(desktop_header))
|
2005-02-21 19:36:47 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!pidl)
|
2010-04-18 16:04:25 +02:00
|
|
|
return SHELL32_GetColumnDetails(desktop_header, iColumn, psd);
|
2002-07-24 03:56:03 +02:00
|
|
|
|
2021-09-10 18:50:19 +02:00
|
|
|
return shellfolder_get_file_details( iface, pidl, desktop_header, iColumn, psd );
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
2005-02-21 19:36:47 +01:00
|
|
|
|
2017-09-25 09:59:36 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID(IShellFolder2 *iface, UINT column, SHCOLUMNID *scid)
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2010-12-04 22:21:57 +01:00
|
|
|
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
|
2017-09-25 09:59:36 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p)\n", This, column, scid);
|
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
if (column >= ARRAY_SIZE(desktop_header))
|
2017-09-25 09:59:36 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return shellfolder_map_column_to_scid(desktop_header, column, scid);
|
2002-07-24 03:56:03 +02:00
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2 =
|
2002-07-24 03:56:03 +02:00
|
|
|
{
|
2005-02-21 19:36:47 +01:00
|
|
|
ISF_Desktop_fnQueryInterface,
|
|
|
|
ISF_Desktop_fnAddRef,
|
|
|
|
ISF_Desktop_fnRelease,
|
|
|
|
ISF_Desktop_fnParseDisplayName,
|
|
|
|
ISF_Desktop_fnEnumObjects,
|
|
|
|
ISF_Desktop_fnBindToObject,
|
|
|
|
ISF_Desktop_fnBindToStorage,
|
|
|
|
ISF_Desktop_fnCompareIDs,
|
|
|
|
ISF_Desktop_fnCreateViewObject,
|
|
|
|
ISF_Desktop_fnGetAttributesOf,
|
|
|
|
ISF_Desktop_fnGetUIObjectOf,
|
|
|
|
ISF_Desktop_fnGetDisplayNameOf,
|
|
|
|
ISF_Desktop_fnSetNameOf,
|
|
|
|
/* ShellFolder2 */
|
|
|
|
ISF_Desktop_fnGetDefaultSearchGUID,
|
|
|
|
ISF_Desktop_fnEnumSearches,
|
|
|
|
ISF_Desktop_fnGetDefaultColumn,
|
|
|
|
ISF_Desktop_fnGetDefaultColumnState,
|
|
|
|
ISF_Desktop_fnGetDetailsEx,
|
|
|
|
ISF_Desktop_fnGetDetailsOf,
|
|
|
|
ISF_Desktop_fnMapColumnToSCID
|
|
|
|
};
|
2005-03-17 14:57:38 +01:00
|
|
|
|
2010-03-21 16:44:44 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IPersist
|
|
|
|
*/
|
2010-07-18 14:34:56 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_IPersistFolder2_fnQueryInterface(
|
|
|
|
IPersistFolder2 *iface, REFIID riid, LPVOID *ppvObj)
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-07-18 14:34:56 +02:00
|
|
|
IDesktopFolderImpl *This = impl_from_IPersistFolder2( iface );
|
2010-12-04 22:21:57 +01:00
|
|
|
return IShellFolder2_QueryInterface(&This->IShellFolder2_iface, riid, ppvObj);
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
static ULONG WINAPI ISF_Desktop_IPersistFolder2_fnAddRef(
|
|
|
|
IPersistFolder2 *iface)
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-07-18 14:34:56 +02:00
|
|
|
IDesktopFolderImpl *This = impl_from_IPersistFolder2( iface );
|
2010-12-04 22:21:57 +01:00
|
|
|
return IShellFolder2_AddRef(&This->IShellFolder2_iface);
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
static ULONG WINAPI ISF_Desktop_IPersistFolder2_fnRelease(
|
|
|
|
IPersistFolder2 *iface)
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-07-18 14:34:56 +02:00
|
|
|
IDesktopFolderImpl *This = impl_from_IPersistFolder2( iface );
|
2010-12-04 22:21:57 +01:00
|
|
|
return IShellFolder2_Release(&This->IShellFolder2_iface);
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_IPersistFolder2_fnGetClassID(
|
|
|
|
IPersistFolder2 *iface, CLSID *clsid)
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
|
|
|
*clsid = CLSID_ShellDesktop;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-07-18 14:34:56 +02:00
|
|
|
static HRESULT WINAPI ISF_Desktop_IPersistFolder2_fnInitialize(
|
|
|
|
IPersistFolder2 *iface, LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
IDesktopFolderImpl *This = impl_from_IPersistFolder2( iface );
|
|
|
|
FIXME ("(%p)->(%p) stub\n", This, pidl);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_Desktop_IPersistFolder2_fnGetCurFolder(
|
|
|
|
IPersistFolder2 *iface, LPITEMIDLIST *ppidl)
|
|
|
|
{
|
|
|
|
IDesktopFolderImpl *This = impl_from_IPersistFolder2( iface );
|
|
|
|
*ppidl = ILClone(This->pidlRoot);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-03-21 16:44:44 +01:00
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
static const IPersistFolder2Vtbl vt_IPersistFolder2 =
|
2010-03-21 16:44:44 +01:00
|
|
|
{
|
2010-07-18 14:34:56 +02:00
|
|
|
ISF_Desktop_IPersistFolder2_fnQueryInterface,
|
|
|
|
ISF_Desktop_IPersistFolder2_fnAddRef,
|
|
|
|
ISF_Desktop_IPersistFolder2_fnRelease,
|
|
|
|
ISF_Desktop_IPersistFolder2_fnGetClassID,
|
|
|
|
ISF_Desktop_IPersistFolder2_fnInitialize,
|
|
|
|
ISF_Desktop_IPersistFolder2_fnGetCurFolder
|
2010-03-21 16:44:44 +01:00
|
|
|
};
|
|
|
|
|
2014-06-14 21:56:45 +02:00
|
|
|
void release_desktop_folder(void)
|
|
|
|
{
|
|
|
|
if (!cached_sf) return;
|
|
|
|
SHFree(cached_sf->pidlRoot);
|
|
|
|
SHFree(cached_sf->sPathTarget);
|
|
|
|
LocalFree(cached_sf);
|
|
|
|
}
|
|
|
|
|
2005-03-17 14:57:38 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ISF_Desktop_Constructor
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ISF_Desktop_Constructor (
|
|
|
|
IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
WCHAR szMyPath[MAX_PATH];
|
|
|
|
|
|
|
|
TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
|
|
|
|
|
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2007-06-21 16:50:55 +02:00
|
|
|
if (!cached_sf)
|
|
|
|
{
|
2010-03-29 23:30:37 +02:00
|
|
|
IDesktopFolderImpl *sf;
|
2005-03-17 14:57:38 +01:00
|
|
|
|
2021-09-17 16:51:31 +02:00
|
|
|
if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, FALSE ))
|
2007-06-21 16:50:55 +02:00
|
|
|
return E_UNEXPECTED;
|
2005-03-17 14:57:38 +01:00
|
|
|
|
2010-03-29 23:30:37 +02:00
|
|
|
sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IDesktopFolderImpl) );
|
2007-06-21 16:50:55 +02:00
|
|
|
if (!sf)
|
|
|
|
return E_OUTOFMEMORY;
|
2005-03-17 14:57:38 +01:00
|
|
|
|
2007-06-21 16:50:55 +02:00
|
|
|
sf->ref = 1;
|
2010-12-04 22:21:57 +01:00
|
|
|
sf->IShellFolder2_iface.lpVtbl = &vt_MCFldr_ShellFolder2;
|
|
|
|
sf->IPersistFolder2_iface.lpVtbl = &vt_IPersistFolder2;
|
2007-06-21 16:50:55 +02:00
|
|
|
sf->pidlRoot = _ILCreateDesktop(); /* my qualified pidl */
|
|
|
|
sf->sPathTarget = SHAlloc( (lstrlenW(szMyPath) + 1)*sizeof(WCHAR) );
|
|
|
|
lstrcpyW( sf->sPathTarget, szMyPath );
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void *)&cached_sf, sf, NULL) != NULL)
|
|
|
|
{
|
|
|
|
/* some other thread already been here */
|
|
|
|
SHFree( sf->pidlRoot );
|
|
|
|
SHFree( sf->sPathTarget );
|
|
|
|
LocalFree( sf );
|
|
|
|
}
|
2005-03-17 14:57:38 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 10:51:05 +02:00
|
|
|
return IShellFolder2_QueryInterface( &cached_sf->IShellFolder2_iface, riid, ppv );
|
2005-03-17 14:57:38 +01:00
|
|
|
}
|