2011-05-15 15:55:49 +00:00
|
|
|
/*
|
2020-04-27 14:11:21 +00:00
|
|
|
* PROJECT: shell32
|
|
|
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
|
|
|
* PURPOSE: file system folder
|
|
|
|
* COPYRIGHT: Copyright 1997 Marcus Meissner
|
|
|
|
* Copyright 1998, 1999, 2002 Juergen Schmied
|
|
|
|
* Copyright 2019 Katayama Hirofumi MZ
|
|
|
|
* Copyright 2020 Mark Jansen (mark.jansen@reactos.org)
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL (shell);
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
static HRESULT SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, LPCWSTR KeyName, CLSID* pclsidFolder);
|
2017-08-18 09:11:59 +00:00
|
|
|
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
HKEY OpenKeyFromFileType(LPWSTR pExtension, LPCWSTR KeyName)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
2017-08-18 09:11:59 +00:00
|
|
|
|
|
|
|
WCHAR FullName[MAX_PATH];
|
|
|
|
DWORD dwSize = sizeof(FullName);
|
|
|
|
wsprintf(FullName, L"%s\\%s", pExtension, KeyName);
|
|
|
|
|
|
|
|
LONG res = RegOpenKeyExW(HKEY_CLASSES_ROOT, FullName, 0, KEY_READ, &hkey);
|
|
|
|
if (!res)
|
|
|
|
return hkey;
|
|
|
|
|
|
|
|
res = RegGetValueW(HKEY_CLASSES_ROOT, pExtension, NULL, RRF_RT_REG_SZ, NULL, FullName, &dwSize);
|
|
|
|
if (res)
|
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
WARN("Failed to get progid for extension %S (%x), error %d\n", pExtension, pExtension, res);
|
2017-08-18 09:11:59 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
wcscat(FullName, L"\\");
|
|
|
|
wcscat(FullName, KeyName);
|
|
|
|
|
|
|
|
hkey = NULL;
|
|
|
|
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, FullName, 0, KEY_READ, &hkey);
|
|
|
|
if (res)
|
|
|
|
WARN("Could not open key %S for extension %S\n", KeyName, pExtension);
|
|
|
|
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
LPWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl)
|
|
|
|
{
|
|
|
|
if (!_ILIsValue(pidl))
|
|
|
|
{
|
|
|
|
ERR("Invalid pidl!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileStructW* pDataW = _ILGetFileStructW(pidl);
|
|
|
|
if (!pDataW)
|
|
|
|
{
|
|
|
|
ERR("Invalid pidl!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPWSTR pExtension = PathFindExtensionW(pDataW->wszName);
|
|
|
|
if (!pExtension || *pExtension == UNICODE_NULL)
|
|
|
|
{
|
|
|
|
WARN("No extension for %S!\n", pDataW->wszName);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return pExtension;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT GetCLSIDForFileTypeFromExtension(LPWSTR pExtension, LPCWSTR KeyName, CLSID* pclsid)
|
2017-08-18 09:11:59 +00:00
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
HKEY hkeyProgId = OpenKeyFromFileType(pExtension, KeyName);
|
2017-08-18 09:11:59 +00:00
|
|
|
if (!hkeyProgId)
|
|
|
|
{
|
|
|
|
WARN("OpenKeyFromFileType failed for key %S\n", KeyName);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR wszCLSIDValue[CHARS_IN_GUID];
|
|
|
|
DWORD dwSize = sizeof(wszCLSIDValue);
|
2017-08-21 09:07:41 +00:00
|
|
|
LONG res = RegGetValueW(hkeyProgId, NULL, NULL, RRF_RT_REG_SZ, NULL, wszCLSIDValue, &dwSize);
|
|
|
|
RegCloseKey(hkeyProgId);
|
|
|
|
if (res)
|
2017-08-18 09:11:59 +00:00
|
|
|
{
|
|
|
|
ERR("OpenKeyFromFileType succeeded but RegGetValueW failed\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
res = RegGetValueW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
|
|
|
|
wszCLSIDValue,
|
|
|
|
RRF_RT_REG_SZ,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("DropHandler extension %S not approved\n", wszName);
|
|
|
|
return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-08-21 12:18:46 +00:00
|
|
|
if (RegGetValueW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Blocked",
|
|
|
|
wszCLSIDValue,
|
|
|
|
RRF_RT_REG_SZ,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Extension %S not approved\n", wszCLSIDValue);
|
|
|
|
return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
HRESULT hres = CLSIDFromString (wszCLSIDValue, pclsid);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
HRESULT GetCLSIDForFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID* pclsid)
|
|
|
|
{
|
|
|
|
LPWSTR pExtension = ExtensionFromPidl(pidl);
|
|
|
|
if (!pExtension)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
return GetCLSIDForFileTypeFromExtension(pExtension, KeyName, pclsid);
|
|
|
|
}
|
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
static HRESULT
|
|
|
|
getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
|
2017-07-15 09:38:45 +00:00
|
|
|
{
|
2018-06-22 13:37:03 +00:00
|
|
|
static const WCHAR folder[] = { 'F', 'o', 'l', 'd', 'e', 'r', 0 };
|
|
|
|
|
|
|
|
if (!HCR_GetIconW(folder, szIconFile, NULL, cchMax, piIndex))
|
|
|
|
{
|
|
|
|
lstrcpynW(szIconFile, swShell32Name, cchMax);
|
|
|
|
*piIndex = -IDI_SHELL_FOLDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uFlags & GIL_OPENICON)
|
|
|
|
{
|
|
|
|
// next icon
|
|
|
|
if (*piIndex < 0)
|
|
|
|
(*piIndex)--;
|
|
|
|
else
|
|
|
|
(*piIndex)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR s_shellClassInfo[] = { '.', 'S', 'h', 'e', 'l', 'l', 'C', 'l', 'a', 's', 's', 'I', 'n', 'f', 'o', 0 };
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
|
|
|
|
{
|
|
|
|
return GetPrivateProfileStringW(s_shellClassInfo, Entry, NULL, pszValue, cchValueLen, IniFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT
|
2018-06-24 17:59:03 +00:00
|
|
|
getIconLocationForFolder(IShellFolder * psf, PCITEMID_CHILD pidl, UINT uFlags,
|
2018-06-22 13:37:03 +00:00
|
|
|
LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
|
|
|
|
{
|
|
|
|
DWORD dwFileAttrs;
|
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
WCHAR wszIniFullPath[MAX_PATH];
|
2017-07-15 09:38:45 +00:00
|
|
|
static const WCHAR iconFile[] = { 'I', 'c', 'o', 'n', 'F', 'i', 'l', 'e', 0 };
|
|
|
|
static const WCHAR clsid[] = { 'C', 'L', 'S', 'I', 'D', 0 };
|
|
|
|
static const WCHAR clsid2[] = { 'C', 'L', 'S', 'I', 'D', '2', 0 };
|
|
|
|
static const WCHAR iconIndex[] = { 'I', 'c', 'o', 'n', 'I', 'n', 'd', 'e', 'x', 0 };
|
2018-06-22 13:37:03 +00:00
|
|
|
static const WCHAR iconResource[] = { 'I', 'c', 'o', 'n', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 0 };
|
2017-07-15 09:38:45 +00:00
|
|
|
static const WCHAR wszDesktopIni[] = { 'd','e','s','k','t','o','p','.','i','n','i',0 };
|
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
if (uFlags & GIL_DEFAULTICON)
|
|
|
|
goto Quit;
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// get path
|
2018-06-24 17:59:03 +00:00
|
|
|
if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
|
|
|
|
goto Quit;
|
2018-06-22 13:37:03 +00:00
|
|
|
if (!PathIsDirectoryW(wszPath))
|
2018-06-24 17:59:03 +00:00
|
|
|
goto Quit;
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// read-only or system folder?
|
2018-06-24 17:59:03 +00:00
|
|
|
dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
|
2018-06-22 13:37:03 +00:00
|
|
|
if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
|
2018-06-24 17:59:03 +00:00
|
|
|
goto Quit;
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// build the full path of ini file
|
|
|
|
StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
|
|
|
|
PathAppendW(wszIniFullPath, wszDesktopIni);
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
|
|
|
|
if (getShellClassInfo(iconFile, wszValue, _countof(wszValue), wszIniFullPath))
|
|
|
|
{
|
|
|
|
// wszValue --> wszTemp
|
|
|
|
ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
|
|
|
|
|
|
|
|
// wszPath + wszTemp --> wszPath
|
|
|
|
if (PathIsRelativeW(wszTemp))
|
|
|
|
PathAppendW(wszPath, wszTemp);
|
|
|
|
else
|
|
|
|
StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// wszPath --> szIconFile
|
|
|
|
GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
|
|
|
|
|
|
|
|
*piIndex = GetPrivateProfileIntW(s_shellClassInfo, iconIndex, 0, wszIniFullPath);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (getShellClassInfo(clsid, wszValue, _countof(wszValue), wszIniFullPath) &&
|
|
|
|
HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
|
2017-07-15 09:38:45 +00:00
|
|
|
{
|
2018-06-22 13:37:03 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (getShellClassInfo(clsid2, wszValue, _countof(wszValue), wszIniFullPath) &&
|
|
|
|
HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
|
|
|
|
{
|
|
|
|
return S_OK;
|
2017-07-15 09:38:45 +00:00
|
|
|
}
|
2018-06-22 13:37:03 +00:00
|
|
|
else if (getShellClassInfo(iconResource, wszValue, _countof(wszValue), wszIniFullPath))
|
|
|
|
{
|
|
|
|
// wszValue --> wszTemp
|
|
|
|
ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// parse the icon location
|
|
|
|
*piIndex = PathParseIconLocationW(wszTemp);
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2018-06-22 13:37:03 +00:00
|
|
|
// wszPath + wszTemp --> wszPath
|
|
|
|
if (PathIsRelativeW(wszTemp))
|
|
|
|
PathAppendW(wszPath, wszTemp);
|
|
|
|
else
|
|
|
|
StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
|
|
|
|
|
|
|
|
// wszPath --> szIconFile
|
|
|
|
GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Quit:
|
|
|
|
return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
|
2017-07-15 09:38:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID iid, LPVOID * ppvOut)
|
|
|
|
{
|
|
|
|
CComPtr<IDefaultExtractIconInit> initIcon;
|
|
|
|
HRESULT hr;
|
|
|
|
int icon_idx = 0;
|
|
|
|
UINT flags = 0; // FIXME: Use it!
|
|
|
|
WCHAR wTemp[MAX_PATH] = L"";
|
|
|
|
|
|
|
|
hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (_ILIsFolder (pidl))
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(getIconLocationForFolder(psf,
|
|
|
|
pidl, 0, wTemp, _countof(wTemp),
|
|
|
|
&icon_idx,
|
|
|
|
&flags)))
|
|
|
|
{
|
|
|
|
initIcon->SetNormalIcon(wTemp, icon_idx);
|
|
|
|
// FIXME: if/when getIconLocationForFolder does something for
|
|
|
|
// GIL_FORSHORTCUT, code below should be uncommented. and
|
|
|
|
// the following line removed.
|
|
|
|
initIcon->SetShortcutIcon(wTemp, icon_idx);
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(getIconLocationForFolder(psf,
|
|
|
|
pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
|
|
|
|
&icon_idx,
|
|
|
|
&flags)))
|
|
|
|
{
|
|
|
|
initIcon->SetDefaultIcon(wTemp, icon_idx);
|
|
|
|
}
|
|
|
|
// if (SUCCEEDED(getIconLocationForFolder(psf,
|
|
|
|
// pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
|
|
|
|
// &icon_idx,
|
|
|
|
// &flags)))
|
|
|
|
// {
|
|
|
|
// initIcon->SetShortcutIcon(wTemp, icon_idx);
|
|
|
|
// }
|
|
|
|
if (SUCCEEDED(getIconLocationForFolder(psf,
|
|
|
|
pidl, GIL_OPENICON, wTemp, _countof(wTemp),
|
|
|
|
&icon_idx,
|
|
|
|
&flags)))
|
|
|
|
{
|
|
|
|
initIcon->SetOpenIcon(wTemp, icon_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
LPWSTR pExtension = ExtensionFromPidl(pidl);
|
|
|
|
HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL;
|
2017-08-18 09:11:59 +00:00
|
|
|
if (!hkey)
|
|
|
|
WARN("Could not open DefaultIcon key!\n");
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
DWORD dwSize = sizeof(wTemp);
|
|
|
|
if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
|
2017-07-15 09:38:45 +00:00
|
|
|
{
|
2017-08-18 09:11:59 +00:00
|
|
|
WCHAR sNum[5];
|
|
|
|
if (ParseFieldW (wTemp, 2, sNum, 5))
|
|
|
|
icon_idx = _wtoi(sNum);
|
|
|
|
else
|
|
|
|
icon_idx = 0; /* sometimes the icon number is missing */
|
|
|
|
ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
|
|
|
|
PathUnquoteSpacesW(wTemp);
|
2017-07-15 09:38:45 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
|
2017-07-15 09:38:45 +00:00
|
|
|
{
|
2019-11-24 10:26:32 +00:00
|
|
|
ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
|
2017-08-18 09:11:59 +00:00
|
|
|
icon_idx = 0;
|
2019-11-26 12:45:58 +00:00
|
|
|
|
|
|
|
INT ret = ExtractIconExW(wTemp, -1, NULL, NULL, 0);
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
|
|
|
|
icon_idx = -IDI_SHELL_EXE;
|
|
|
|
}
|
2017-07-15 09:38:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
initIcon->SetNormalIcon(wTemp, icon_idx);
|
2017-08-18 09:11:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
initIcon->SetNormalIcon(swShell32Name, 0);
|
|
|
|
}
|
2017-08-21 09:07:41 +00:00
|
|
|
|
|
|
|
if (hkey)
|
|
|
|
RegCloseKey(hkey);
|
2017-07-15 09:38:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return initIcon->QueryInterface(iid, ppvOut);
|
|
|
|
}
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
/*
|
|
|
|
CFileSysEnum should do an initial FindFirstFile and do a FindNextFile as each file is
|
|
|
|
returned by Next. When the enumerator is created, it can do numerous additional operations
|
|
|
|
including formatting a drive, reconnecting a network share drive, and requesting a disk
|
|
|
|
be inserted in a removable drive.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class CFileSysEnum :
|
2014-11-04 12:49:36 +00:00
|
|
|
public CEnumIDListBase
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
private:
|
|
|
|
HRESULT _AddFindResult(LPWSTR sParentDir, const WIN32_FIND_DATAW& FindData, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
#define SUPER_HIDDEN (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)
|
2011-12-17 22:53:44 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
// Does it need special handling because it is hidden?
|
|
|
|
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
|
|
|
|
{
|
|
|
|
DWORD dwHidden = FindData.dwFileAttributes & SUPER_HIDDEN;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
// Is it hidden, but are we not asked to include hidden?
|
|
|
|
if (dwHidden == FILE_ATTRIBUTE_HIDDEN && !(dwFlags & SHCONTF_INCLUDEHIDDEN))
|
|
|
|
return S_OK;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
// Is it a system file, but are we not asked to include those?
|
|
|
|
if (dwHidden == SUPER_HIDDEN && !(dwFlags & SHCONTF_INCLUDESUPERHIDDEN))
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
BOOL bDirectory = (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
|
|
|
|
2020-04-27 18:43:16 +00:00
|
|
|
HRESULT hr;
|
|
|
|
if (bDirectory)
|
|
|
|
{
|
|
|
|
// Skip the current and parent directory nodes
|
|
|
|
if (!strcmpW(FindData.cFileName, L".") || !strcmpW(FindData.cFileName, L".."))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
// Does this directory need special handling?
|
|
|
|
if ((FindData.dwFileAttributes & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) != 0)
|
|
|
|
{
|
|
|
|
WCHAR Tmp[MAX_PATH];
|
|
|
|
CLSID clsidFolder;
|
|
|
|
|
|
|
|
PathCombineW(Tmp, sParentDir, FindData.cFileName);
|
|
|
|
|
|
|
|
hr = SHELL32_GetCLSIDForDirectory(Tmp, L"CLSID", &clsidFolder);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ERR("SHOULD DO SOMETHING WITH CLSID?\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CLSID clsidFile;
|
|
|
|
LPWSTR pExtension = PathFindExtensionW(FindData.cFileName);
|
|
|
|
if (pExtension)
|
|
|
|
{
|
|
|
|
// FIXME: Cache this?
|
|
|
|
hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
::RegCloseKey(hkey);
|
|
|
|
|
|
|
|
// This should be presented as directory!
|
|
|
|
bDirectory = TRUE;
|
|
|
|
TRACE("Treating '%S' as directory!\n", FindData.cFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
if (bDirectory)
|
|
|
|
{
|
|
|
|
if (dwFlags & SHCONTF_FOLDERS)
|
|
|
|
{
|
|
|
|
TRACE("(%p)-> (folder=%s)\n", this, debugstr_w(FindData.cFileName));
|
|
|
|
pidl = _ILCreateFromFindDataW(&FindData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dwFlags & SHCONTF_NONFOLDERS)
|
|
|
|
{
|
|
|
|
TRACE("(%p)-> (file =%s)\n", this, debugstr_w(FindData.cFileName));
|
|
|
|
pidl = _ILCreateFromFindDataW(&FindData);
|
|
|
|
}
|
|
|
|
}
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
if (pidl && !AddToEnumList(pidl))
|
|
|
|
{
|
|
|
|
FAILED_UNEXPECTEDLY(E_FAIL);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
public:
|
|
|
|
CFileSysEnum()
|
|
|
|
{
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
}
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
~CFileSysEnum()
|
2017-07-15 09:18:06 +00:00
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
}
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
HRESULT WINAPI Initialize(LPWSTR sPathTarget, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(path=%s flags=0x%08x)\n", this, debugstr_w(sPathTarget), dwFlags);
|
|
|
|
|
|
|
|
if (!sPathTarget || !sPathTarget[0])
|
|
|
|
{
|
2020-05-19 18:35:52 +00:00
|
|
|
WARN("No path for CFileSysEnum, empty result!\n");
|
|
|
|
return S_FALSE;
|
2020-04-27 14:11:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR szFindPattern[MAX_PATH];
|
|
|
|
HRESULT hr = StringCchCopyW(szFindPattern, _countof(szFindPattern), sPathTarget);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* FIXME: UNSAFE CRAP */
|
|
|
|
PathAddBackslashW(szFindPattern);
|
|
|
|
|
|
|
|
hr = StringCchCatW(szFindPattern, _countof(szFindPattern), L"*.*");
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
|
|
|
|
WIN32_FIND_DATAW FindData;
|
|
|
|
HANDLE hFind = FindFirstFileW(szFindPattern, &FindData);
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
2019-11-29 06:14:18 +00:00
|
|
|
|
2017-07-15 09:18:06 +00:00
|
|
|
do
|
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
hr = _AddFindResult(sPathTarget, FindData, dwFlags);
|
2017-07-15 09:18:06 +00:00
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
break;
|
|
|
|
|
|
|
|
} while(FindNextFileW(hFind, &FindData));
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
if (dwError != ERROR_NO_MORE_FILES)
|
2017-07-15 09:18:06 +00:00
|
|
|
{
|
2020-04-27 14:11:21 +00:00
|
|
|
hr = HRESULT_FROM_WIN32(dwError);
|
|
|
|
FAILED_UNEXPECTEDLY(hr);
|
2017-07-15 09:18:06 +00:00
|
|
|
}
|
2020-04-27 14:11:21 +00:00
|
|
|
}
|
|
|
|
TRACE("(%p)->(hr=0x%08x)\n", this, hr);
|
|
|
|
FindClose(hFind);
|
|
|
|
return hr;
|
2017-07-15 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:21 +00:00
|
|
|
BEGIN_COM_MAP(CFileSysEnum)
|
|
|
|
COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
|
|
|
|
END_COM_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IShellFolder implementation
|
|
|
|
*/
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
CFSFolder::CFSFolder()
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
m_pclsid = &CLSID_ShellFSFolder;
|
|
|
|
m_sPathTarget = NULL;
|
|
|
|
m_pidlRoot = NULL;
|
2014-03-15 13:59:22 +00:00
|
|
|
m_bGroupPolicyActive = 0;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CFSFolder::~CFSFolder()
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("-- destroying IShellFolder(%p)\n", this);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
SHFree(m_pidlRoot);
|
|
|
|
SHFree(m_sPathTarget);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const shvheader GenericSFHeader[] = {
|
2017-06-12 10:01:28 +00:00
|
|
|
{IDS_SHV_COLUMN_NAME, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 15},
|
2017-06-12 18:38:26 +00:00
|
|
|
{IDS_SHV_COLUMN_COMMENTS, SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 0},
|
2017-06-12 10:01:28 +00:00
|
|
|
{IDS_SHV_COLUMN_TYPE, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 10},
|
2017-06-12 18:38:26 +00:00
|
|
|
{IDS_SHV_COLUMN_SIZE, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
|
2017-06-12 10:01:28 +00:00
|
|
|
{IDS_SHV_COLUMN_MODIFIED, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12},
|
|
|
|
{IDS_SHV_COLUMN_ATTRIBUTES, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 10}
|
2011-05-15 15:55:49 +00:00
|
|
|
};
|
|
|
|
|
2017-06-12 18:38:26 +00:00
|
|
|
#define GENERICSHELLVIEWCOLUMNS 6
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* SHELL32_CreatePidlFromBindCtx [internal]
|
|
|
|
*
|
|
|
|
* If the caller bound File System Bind Data, assume it is the
|
|
|
|
* find data for the path.
|
|
|
|
* This allows binding of paths that don't exist.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path)
|
|
|
|
{
|
|
|
|
IFileSystemBindData *fsbd = NULL;
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
IUnknown *param = NULL;
|
|
|
|
WIN32_FIND_DATAW wfd;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %s\n", pbc, debugstr_w(path));
|
|
|
|
|
|
|
|
if (!pbc)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* see if the caller bound File System Bind Data */
|
2013-11-24 21:42:28 +00:00
|
|
|
r = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, ¶m);
|
2011-05-15 15:55:49 +00:00
|
|
|
if (FAILED(r))
|
|
|
|
return NULL;
|
|
|
|
|
2013-11-11 16:42:16 +00:00
|
|
|
r = param->QueryInterface(IID_PPV_ARG(IFileSystemBindData,&fsbd));
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(r))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
r = fsbd->GetFindData(&wfd);
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(r))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
lstrcpynW(&wfd.cFileName[0], path, MAX_PATH);
|
|
|
|
pidl = _ILCreateFromFindDataW(&wfd);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
fsbd->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
2019-08-04 00:42:09 +00:00
|
|
|
static HRESULT SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, LPCWSTR KeyName, CLSID* pclsidFolder)
|
2017-07-07 20:34:27 +00:00
|
|
|
{
|
|
|
|
WCHAR wszCLSIDValue[CHARS_IN_GUID];
|
|
|
|
WCHAR wszDesktopIni[MAX_PATH];
|
|
|
|
StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
|
|
|
|
StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
|
|
|
|
|
2019-08-04 00:42:09 +00:00
|
|
|
if (GetPrivateProfileStringW(L".ShellClassInfo",
|
|
|
|
KeyName,
|
2017-07-07 20:34:27 +00:00
|
|
|
L"",
|
2019-08-04 00:42:09 +00:00
|
|
|
wszCLSIDValue,
|
|
|
|
CHARS_IN_GUID,
|
2017-07-07 20:34:27 +00:00
|
|
|
wszDesktopIni))
|
|
|
|
{
|
2019-08-04 00:42:09 +00:00
|
|
|
return CLSIDFromString(wszCLSIDValue, pclsidFolder);
|
2017-07-07 20:34:27 +00:00
|
|
|
}
|
2019-08-04 00:42:09 +00:00
|
|
|
return E_FAIL;
|
2017-07-07 20:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT SHELL32_GetFSItemAttributes(IShellFolder * psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
|
|
|
|
{
|
|
|
|
DWORD dwFileAttributes, dwShellAttributes;
|
|
|
|
|
|
|
|
if (!_ILIsFolder(pidl) && !_ILIsValue(pidl))
|
|
|
|
{
|
|
|
|
ERR("Got wrong type of pidl!\n");
|
|
|
|
*pdwAttributes &= SFGAO_CANLINK;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
|
|
|
|
|
|
|
|
/* Set common attributes */
|
2018-02-18 23:59:30 +00:00
|
|
|
dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
|
|
|
|
SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
|
2017-07-07 20:34:27 +00:00
|
|
|
|
2020-04-27 18:43:16 +00:00
|
|
|
BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
|
|
|
|
|
|
|
if (!bDirectory)
|
|
|
|
{
|
|
|
|
// https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
|
|
|
|
WCHAR szFileName[MAX_PATH];
|
|
|
|
LPWSTR pExtension;
|
|
|
|
|
|
|
|
if (_ILSimpleGetTextW(pidl, szFileName, _countof(szFileName)) && (pExtension = PathFindExtensionW(szFileName)))
|
|
|
|
{
|
|
|
|
CLSID clsidFile;
|
|
|
|
// FIXME: Cache this?
|
|
|
|
HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
DWORD dwAttributes = 0;
|
|
|
|
DWORD dwSize = sizeof(dwAttributes);
|
|
|
|
LSTATUS Status;
|
|
|
|
|
|
|
|
Status = SHRegGetValueW(hkey, NULL, L"Attributes", RRF_RT_REG_DWORD, NULL, &dwAttributes, &dwSize);
|
|
|
|
if (Status == STATUS_SUCCESS)
|
|
|
|
{
|
2020-08-22 22:35:02 +00:00
|
|
|
TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
|
2020-04-27 18:43:16 +00:00
|
|
|
dwShellAttributes |= dwAttributes;
|
|
|
|
}
|
|
|
|
::RegCloseKey(hkey);
|
|
|
|
|
|
|
|
// This should be presented as directory!
|
|
|
|
bDirectory = TRUE;
|
2020-08-22 22:35:02 +00:00
|
|
|
TRACE("Treating '%S' as directory!\n", szFileName);
|
2020-04-27 18:43:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is a directory
|
|
|
|
if (bDirectory)
|
|
|
|
{
|
|
|
|
dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
|
|
|
|
|
|
|
|
// Is this a real directory?
|
|
|
|
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
{
|
|
|
|
dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
|
|
|
|
}
|
|
|
|
}
|
2017-07-07 20:34:27 +00:00
|
|
|
else
|
2020-04-27 18:43:16 +00:00
|
|
|
{
|
2018-02-18 23:59:30 +00:00
|
|
|
dwShellAttributes |= SFGAO_STREAM;
|
2020-04-27 18:43:16 +00:00
|
|
|
}
|
2017-07-07 20:34:27 +00:00
|
|
|
|
|
|
|
if (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
|
|
|
|
dwShellAttributes |= SFGAO_HIDDEN;
|
|
|
|
|
|
|
|
if (dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
|
|
|
dwShellAttributes |= SFGAO_READONLY;
|
|
|
|
|
|
|
|
if (SFGAO_LINK & *pdwAttributes)
|
|
|
|
{
|
|
|
|
char ext[MAX_PATH];
|
|
|
|
|
2018-02-18 23:59:30 +00:00
|
|
|
if (_ILGetExtension(pidl, ext, MAX_PATH) && !lstrcmpiA(ext, "lnk"))
|
|
|
|
dwShellAttributes |= SFGAO_LINK;
|
2017-07-07 20:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SFGAO_HASSUBFOLDER & *pdwAttributes)
|
|
|
|
{
|
|
|
|
CComPtr<IShellFolder> psf2;
|
|
|
|
if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
|
|
|
|
{
|
|
|
|
CComPtr<IEnumIDList> pEnumIL;
|
|
|
|
if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
|
|
|
|
{
|
2018-02-18 23:59:30 +00:00
|
|
|
if (pEnumIL->Skip(1) == S_OK)
|
|
|
|
dwShellAttributes |= SFGAO_HASSUBFOLDER;
|
2017-07-07 20:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-18 23:59:30 +00:00
|
|
|
*pdwAttributes = dwShellAttributes;
|
2017-07-07 20:34:27 +00:00
|
|
|
|
|
|
|
TRACE ("-- 0x%08x\n", *pdwAttributes);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::ParseDisplayName {SHELL32}
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Parse a display name.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hwndOwner [in] Parent window for any message's
|
|
|
|
* pbc [in] optional FileSystemBindData context
|
|
|
|
* lpszDisplayName [in] Unicode displayname.
|
|
|
|
* pchEaten [out] (unicode) characters processed
|
|
|
|
* ppidl [out] complex pidl to item
|
|
|
|
* pdwAttributes [out] items attributes
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Every folder tries to parse only its own (the leftmost) pidl and creates a
|
|
|
|
* subfolder to evaluate the remaining parts.
|
|
|
|
* Now we can parse into namespaces implemented by shell extensions
|
|
|
|
*
|
|
|
|
* Behaviour on win98: lpszDisplayName=NULL -> crash
|
|
|
|
* lpszDisplayName="" -> returns mycoputer-pidl
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* pdwAttributes is not set
|
|
|
|
* pchEaten is not set like in windows
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::ParseDisplayName(HWND hwndOwner,
|
2011-12-17 22:53:44 +00:00
|
|
|
LPBC pbc,
|
|
|
|
LPOLESTR lpszDisplayName,
|
2014-08-15 10:38:11 +00:00
|
|
|
DWORD *pchEaten, PIDLIST_RELATIVE *ppidl,
|
2011-12-17 22:53:44 +00:00
|
|
|
DWORD *pdwAttributes)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
LPCWSTR szNext = NULL;
|
|
|
|
WCHAR szElement[MAX_PATH];
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
LPITEMIDLIST pidlTemp = NULL;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
|
2011-12-17 22:53:44 +00:00
|
|
|
this, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
|
|
|
|
pchEaten, ppidl, pdwAttributes);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-08 14:07:02 +00:00
|
|
|
if (!ppidl)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2011-09-08 14:07:02 +00:00
|
|
|
if (!lpszDisplayName)
|
|
|
|
{
|
|
|
|
*ppidl = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppidl = NULL;
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
if (pchEaten)
|
|
|
|
*pchEaten = 0; /* strange but like the original */
|
|
|
|
|
2013-11-24 21:42:28 +00:00
|
|
|
if (*lpszDisplayName)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
/* get the next element */
|
|
|
|
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
|
|
|
|
|
2013-11-24 21:42:28 +00:00
|
|
|
pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, szElement);
|
|
|
|
if (pidlTemp != NULL)
|
|
|
|
{
|
2015-08-31 23:44:02 +00:00
|
|
|
/* We are creating an id list without ensuring that the items exist.
|
|
|
|
If we have a remaining path, this must be a folder.
|
|
|
|
We have to do it now because it is set as a file by default */
|
|
|
|
if (szNext)
|
|
|
|
{
|
|
|
|
pidlTemp->mkid.abID[0] = PT_FOLDER;
|
|
|
|
}
|
2013-11-24 21:42:28 +00:00
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* build the full pathname to the element */
|
2019-12-04 20:35:25 +00:00
|
|
|
lstrcpynW(szPath, m_sPathTarget, MAX_PATH - 1);
|
2013-11-24 21:42:28 +00:00
|
|
|
PathAddBackslashW(szPath);
|
|
|
|
len = wcslen(szPath);
|
|
|
|
lstrcpynW(szPath + len, szElement, MAX_PATH - len);
|
|
|
|
|
|
|
|
/* get the pidl */
|
|
|
|
hr = _ILCreateFromPathW(szPath, &pidlTemp);
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (szNext && *szNext)
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
/* try to analyse the next element */
|
2011-12-18 21:54:04 +00:00
|
|
|
hr = SHELL32_ParseNextElement(this, hwndOwner, pbc,
|
|
|
|
&pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
/* it's the last element */
|
2011-12-18 21:54:04 +00:00
|
|
|
if (pdwAttributes && *pdwAttributes)
|
2015-08-17 11:41:15 +00:00
|
|
|
hr = SHELL32_GetFSItemAttributes(this, pidlTemp, pdwAttributes);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
*ppidl = pidlTemp;
|
|
|
|
else
|
|
|
|
*ppidl = NULL;
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("(%p)->(-- pidl=%p ret=0x%08x)\n", this, ppidl ? *ppidl : 0, hr);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::EnumObjects
|
2011-05-15 15:55:49 +00:00
|
|
|
* PARAMETERS
|
|
|
|
* HWND hwndOwner, //[in ] Parent Window
|
|
|
|
* DWORD grfFlags, //[in ] SHCONTF enumeration mask
|
|
|
|
* LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
|
|
|
|
*/
|
2011-12-18 21:54:04 +00:00
|
|
|
HRESULT WINAPI CFSFolder::EnumObjects(
|
|
|
|
HWND hwndOwner,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPENUMIDLIST *ppEnumIDList)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
return ShellObjectCreatorInit<CFileSysEnum>(m_sPathTarget, dwFlags, IID_PPV_ARG(IEnumIDList, ppEnumIDList));
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::BindToObject
|
2011-05-15 15:55:49 +00:00
|
|
|
* PARAMETERS
|
|
|
|
* LPCITEMIDLIST pidl, //[in ] relative pidl to open
|
|
|
|
* LPBC pbc, //[in ] optional FileSystemBindData context
|
|
|
|
* REFIID riid, //[in ] Initial Interface
|
|
|
|
* LPVOID* ppvObject //[out] Interface*
|
|
|
|
*/
|
2011-12-18 21:54:04 +00:00
|
|
|
HRESULT WINAPI CFSFolder::BindToObject(
|
2014-08-15 10:38:11 +00:00
|
|
|
PCUIDLIST_RELATIVE pidl,
|
2011-12-18 21:54:04 +00:00
|
|
|
LPBC pbc,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", this, pidl, pbc,
|
|
|
|
shdebugstr_guid(&riid), ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
CComPtr<IShellFolder> pSF;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
if (!m_pidlRoot || !ppvOut || !pidl || !pidl->mkid.cb)
|
2017-07-07 20:34:27 +00:00
|
|
|
{
|
2017-08-18 09:11:59 +00:00
|
|
|
ERR("CFSFolder::BindToObject: Invalid parameters\n");
|
|
|
|
return E_INVALIDARG;
|
2017-07-07 20:34:27 +00:00
|
|
|
}
|
2017-08-18 09:11:59 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
/* Get the pidl data */
|
|
|
|
FileStruct* pData = &_ILGetDataPointer(pidl)->u.file;
|
|
|
|
FileStructW* pDataW = _ILGetFileStructW(pidl);
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
if (!pDataW)
|
|
|
|
{
|
|
|
|
ERR("CFSFolder::BindToObject: Invalid pidl!\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
/* Create the target folder info */
|
|
|
|
PERSIST_FOLDER_TARGET_INFO pfti = {0};
|
|
|
|
pfti.dwAttributes = -1;
|
|
|
|
pfti.csidl = -1;
|
2019-12-04 20:35:25 +00:00
|
|
|
PathCombineW(pfti.szTargetParsingName, m_sPathTarget, pDataW->wszName);
|
2017-07-07 20:34:27 +00:00
|
|
|
|
|
|
|
/* Get the CLSID to bind to */
|
2017-08-18 09:11:59 +00:00
|
|
|
CLSID clsidFolder;
|
|
|
|
if (_ILIsFolder(pidl))
|
|
|
|
{
|
|
|
|
clsidFolder = CLSID_ShellFSFolder;
|
|
|
|
|
|
|
|
if ((pData->uFileAttribs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) != 0)
|
2019-08-04 00:42:09 +00:00
|
|
|
SHELL32_GetCLSIDForDirectory(pfti.szTargetParsingName, L"CLSID", &clsidFolder);
|
2017-08-18 09:11:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = GetCLSIDForFileType(pidl, L"CLSID", &clsidFolder);
|
|
|
|
if (hr == S_FALSE)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
}
|
2017-07-07 20:34:27 +00:00
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = SHELL32_BindToSF(m_pidlRoot, &pfti, pidl, &clsidFolder, riid, ppvOut);
|
2017-07-07 20:34:27 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
TRACE ("-- returning (%p) %08x\n", *ppvOut, hr);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::BindToStorage
|
2011-05-15 15:55:49 +00:00
|
|
|
* PARAMETERS
|
|
|
|
* LPCITEMIDLIST pidl, //[in ] complex pidl to store
|
|
|
|
* LPBC pbc, //[in ] reserved
|
|
|
|
* REFIID riid, //[in ] Initial storage interface
|
|
|
|
* LPVOID* ppvObject //[out] Interface* returned
|
|
|
|
*/
|
2011-12-18 21:54:04 +00:00
|
|
|
HRESULT WINAPI CFSFolder::BindToStorage(
|
2014-08-15 10:38:11 +00:00
|
|
|
PCUIDLIST_RELATIVE pidl,
|
2011-12-18 21:54:04 +00:00
|
|
|
LPBC pbcReserved,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", this, pidl, pbcReserved,
|
|
|
|
shdebugstr_guid (&riid), ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::CompareIDs
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::CompareIDs(LPARAM lParam,
|
2014-08-15 10:38:11 +00:00
|
|
|
PCUIDLIST_RELATIVE pidl1,
|
|
|
|
PCUIDLIST_RELATIVE pidl2)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2015-10-26 15:07:44 +00:00
|
|
|
LPPIDLDATA pData1 = _ILGetDataPointer(pidl1);
|
|
|
|
LPPIDLDATA pData2 = _ILGetDataPointer(pidl2);
|
|
|
|
FileStructW* pDataW1 = _ILGetFileStructW(pidl1);
|
|
|
|
FileStructW* pDataW2 = _ILGetFileStructW(pidl2);
|
|
|
|
BOOL bIsFolder1 = _ILIsFolder(pidl1);
|
|
|
|
BOOL bIsFolder2 = _ILIsFolder(pidl2);
|
|
|
|
LPWSTR pExtension1, pExtension2;
|
|
|
|
|
|
|
|
if (!pDataW1 || !pDataW2 || LOWORD(lParam) >= GENERICSHELLVIEWCOLUMNS)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* When sorting between a File and a Folder, the Folder gets sorted first */
|
|
|
|
if (bIsFolder1 != bIsFolder2)
|
|
|
|
{
|
|
|
|
return MAKE_COMPARE_HRESULT(bIsFolder1 ? -1 : 1);
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2015-10-26 15:07:44 +00:00
|
|
|
int result;
|
|
|
|
switch (LOWORD(lParam))
|
|
|
|
{
|
|
|
|
case 0: /* Name */
|
|
|
|
result = wcsicmp(pDataW1->wszName, pDataW2->wszName);
|
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 1: /* Comments */
|
|
|
|
result = 0;
|
|
|
|
break;
|
2015-10-26 15:07:44 +00:00
|
|
|
case 2: /* Type */
|
|
|
|
pExtension1 = PathFindExtensionW(pDataW1->wszName);
|
|
|
|
pExtension2 = PathFindExtensionW(pDataW2->wszName);
|
|
|
|
result = wcsicmp(pExtension1, pExtension2);
|
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 3: /* Size */
|
2020-08-17 16:17:24 +00:00
|
|
|
if (pData1->u.file.dwFileSize > pData2->u.file.dwFileSize)
|
|
|
|
result = 1;
|
|
|
|
else if (pData1->u.file.dwFileSize < pData2->u.file.dwFileSize)
|
|
|
|
result = -1;
|
|
|
|
else
|
|
|
|
result = 0;
|
2015-10-26 15:07:44 +00:00
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 4: /* Modified */
|
2015-10-26 15:07:44 +00:00
|
|
|
result = pData1->u.file.uFileDate - pData2->u.file.uFileDate;
|
|
|
|
if (result == 0)
|
|
|
|
result = pData1->u.file.uFileTime - pData2->u.file.uFileTime;
|
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 5: /* Attributes */
|
2015-10-26 15:07:44 +00:00
|
|
|
return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
|
|
|
|
}
|
2016-11-04 23:11:29 +00:00
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
|
|
|
|
|
2015-10-26 15:07:44 +00:00
|
|
|
return MAKE_COMPARE_HRESULT(result);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::CreateViewObject
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::CreateViewObject(HWND hwndOwner,
|
2011-12-17 22:53:44 +00:00
|
|
|
REFIID riid, LPVOID * ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2014-08-20 00:39:40 +00:00
|
|
|
CComPtr<IShellView> pShellView;
|
2011-05-15 15:55:49 +00:00
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE ("(%p)->(hwnd=%p,%s,%p)\n", this, hwndOwner, shdebugstr_guid (&riid),
|
2011-12-17 22:53:44 +00:00
|
|
|
ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (ppvOut)
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
*ppvOut = NULL;
|
|
|
|
|
2019-08-04 00:42:09 +00:00
|
|
|
BOOL bIsDropTarget = IsEqualIID (riid, IID_IDropTarget);
|
|
|
|
BOOL bIsShellView = !bIsDropTarget && IsEqualIID (riid, IID_IShellView);
|
|
|
|
|
|
|
|
if (bIsDropTarget || bIsShellView)
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
DWORD dwDirAttributes = _ILGetFileAttributes(ILFindLastID(m_pidlRoot), NULL, 0);
|
2019-08-04 00:42:09 +00:00
|
|
|
|
|
|
|
if ((dwDirAttributes & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) != 0)
|
|
|
|
{
|
|
|
|
CLSID clsidFolder;
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = SHELL32_GetCLSIDForDirectory(m_sPathTarget, L"UICLSID", &clsidFolder);
|
2019-08-04 00:42:09 +00:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
CComPtr<IPersistFolder> spFolder;
|
|
|
|
hr = SHCoCreateInstance(NULL, &clsidFolder, NULL, IID_PPV_ARG(IPersistFolder, &spFolder));
|
|
|
|
if (!FAILED_UNEXPECTEDLY(hr))
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = spFolder->Initialize(m_pidlRoot);
|
2019-08-04 00:42:09 +00:00
|
|
|
|
|
|
|
if (!FAILED_UNEXPECTEDLY(hr))
|
|
|
|
{
|
|
|
|
hr = spFolder->QueryInterface(riid, ppvOut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No desktop.ini, or no UICLSID present, continue as if nothing happened
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
2019-08-04 00:42:09 +00:00
|
|
|
|
|
|
|
if (!SUCCEEDED(hr))
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2019-08-04 00:42:09 +00:00
|
|
|
// No UICLSID handler found, continue to the default handlers
|
|
|
|
if (bIsDropTarget)
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = CFSDropTarget_CreateInstance(m_sPathTarget, riid, ppvOut);
|
2019-08-04 00:42:09 +00:00
|
|
|
}
|
|
|
|
else if (IsEqualIID (riid, IID_IContextMenu))
|
|
|
|
{
|
|
|
|
HKEY hKeys[16];
|
|
|
|
UINT cKeys = 0;
|
|
|
|
AddClassKeyToArray(L"Directory\\Background", hKeys, &cKeys);
|
|
|
|
|
|
|
|
DEFCONTEXTMENU dcm;
|
|
|
|
dcm.hwnd = hwndOwner;
|
|
|
|
dcm.pcmcb = this;
|
2019-12-04 20:35:25 +00:00
|
|
|
dcm.pidlFolder = m_pidlRoot;
|
2019-08-04 00:42:09 +00:00
|
|
|
dcm.psf = this;
|
|
|
|
dcm.cidl = 0;
|
|
|
|
dcm.apidl = NULL;
|
|
|
|
dcm.cKeys = cKeys;
|
|
|
|
dcm.aKeys = hKeys;
|
|
|
|
dcm.punkAssociationInfo = NULL;
|
|
|
|
hr = SHCreateDefaultContextMenu (&dcm, riid, ppvOut);
|
|
|
|
}
|
|
|
|
else if (bIsShellView)
|
|
|
|
{
|
|
|
|
SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this, NULL, this};
|
|
|
|
hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("-- (%p)->(interface=%p)\n", this, ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::GetAttributesOf
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* UINT cidl, //[in ] num elements in pidl array
|
|
|
|
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
|
|
|
|
* ULONG* rgfInOut) //[out] result array
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::GetAttributesOf(UINT cidl,
|
2014-08-15 10:38:11 +00:00
|
|
|
PCUITEMID_CHILD_ARRAY apidl, DWORD * rgfInOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (!rgfInOut)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (cidl && !apidl)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (*rgfInOut == 0)
|
|
|
|
*rgfInOut = ~0;
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if(cidl == 0)
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
LPCITEMIDLIST rpidl = ILFindLastID(m_pidlRoot);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2015-08-17 11:41:15 +00:00
|
|
|
if (_ILIsFolder(rpidl) || _ILIsValue(rpidl))
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2015-08-17 11:41:15 +00:00
|
|
|
SHELL32_GetFSItemAttributes(this, rpidl, rgfInOut);
|
|
|
|
}
|
|
|
|
else if (_ILIsDrive(rpidl))
|
|
|
|
{
|
|
|
|
IShellFolder *psfParent = NULL;
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = SHBindToParent(m_pidlRoot, IID_PPV_ARG(IShellFolder, &psfParent), NULL);
|
2015-08-17 11:41:15 +00:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = psfParent->GetAttributesOf(1, &rpidl, (SFGAOF*)rgfInOut);
|
|
|
|
psfParent->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-17 11:46:22 +00:00
|
|
|
ERR("Got and unknown pidl!\n");
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while (cidl > 0 && *apidl)
|
|
|
|
{
|
|
|
|
pdump(*apidl);
|
2015-04-03 11:44:30 +00:00
|
|
|
if(_ILIsFolder(*apidl) || _ILIsValue(*apidl))
|
2015-08-17 11:41:15 +00:00
|
|
|
SHELL32_GetFSItemAttributes(this, *apidl, rgfInOut);
|
2015-04-03 11:44:30 +00:00
|
|
|
else
|
|
|
|
ERR("Got an unknown type of pidl!!!\n");
|
2011-05-15 15:55:49 +00:00
|
|
|
apidl++;
|
|
|
|
cidl--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
|
|
|
|
*rgfInOut &= ~SFGAO_VALIDATE;
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("-- result=0x%08x\n", *rgfInOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::GetUIObjectOf
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This function gets asked to return "view objects" for one or more (multiple
|
|
|
|
* select) items:
|
|
|
|
* The viewobject typically is an COM object with one of the following
|
|
|
|
* interfaces:
|
|
|
|
* IExtractIcon,IDataObject,IContextMenu
|
|
|
|
* In order to support icon positions in the default Listview your DataObject
|
|
|
|
* must implement the SetData method (in addition to GetData :) - the shell
|
|
|
|
* passes a barely documented "Icon positions" structure to SetData when the
|
|
|
|
* drag starts, and GetData's it if the drop is in another explorer window that
|
|
|
|
* needs the positions.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
|
2014-08-15 10:38:11 +00:00
|
|
|
UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
|
|
|
|
REFIID riid, UINT * prgfInOut,
|
|
|
|
LPVOID * ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2016-05-01 19:54:23 +00:00
|
|
|
LPVOID pObj = NULL;
|
2011-05-15 15:55:49 +00:00
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
|
2011-12-17 22:53:44 +00:00
|
|
|
this, hwndOwner, cidl, apidl, shdebugstr_guid (&riid), prgfInOut, ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (ppvOut)
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
*ppvOut = NULL;
|
|
|
|
|
2017-08-21 12:18:46 +00:00
|
|
|
if (cidl == 1 && _ILIsValue(apidl[0]))
|
2017-08-18 09:11:59 +00:00
|
|
|
{
|
|
|
|
hr = _CreateExtensionUIObject(apidl[0], riid, ppvOut);
|
|
|
|
if(hr != S_FALSE)
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-04-28 21:59:02 +00:00
|
|
|
if (IsEqualIID(riid, IID_IContextMenu) && (cidl >= 1))
|
|
|
|
{
|
2016-11-15 20:14:56 +00:00
|
|
|
HKEY hKeys[16];
|
|
|
|
UINT cKeys = 0;
|
|
|
|
AddFSClassKeysToArray(apidl[0], hKeys, &cKeys);
|
2016-11-17 14:35:19 +00:00
|
|
|
|
|
|
|
DEFCONTEXTMENU dcm;
|
|
|
|
dcm.hwnd = hwndOwner;
|
|
|
|
dcm.pcmcb = this;
|
2019-12-04 20:35:25 +00:00
|
|
|
dcm.pidlFolder = m_pidlRoot;
|
2016-11-17 14:35:19 +00:00
|
|
|
dcm.psf = this;
|
|
|
|
dcm.cidl = cidl;
|
|
|
|
dcm.apidl = apidl;
|
|
|
|
dcm.cKeys = cKeys;
|
|
|
|
dcm.aKeys = hKeys;
|
|
|
|
dcm.punkAssociationInfo = NULL;
|
|
|
|
hr = SHCreateDefaultContextMenu (&dcm, riid, &pObj);
|
2014-04-28 21:59:02 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
else if (IsEqualIID (riid, IID_IDataObject))
|
|
|
|
{
|
2014-04-28 21:59:02 +00:00
|
|
|
if (cidl >= 1)
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
2011-09-08 22:43:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-29 15:38:55 +00:00
|
|
|
hr = E_INVALIDARG;
|
2011-09-08 22:43:43 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
2016-05-01 19:54:23 +00:00
|
|
|
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2017-08-21 12:18:46 +00:00
|
|
|
if (_ILIsValue(apidl[0]))
|
|
|
|
hr = _GetIconHandler(apidl[0], riid, (LPVOID*)&pObj);
|
2017-08-18 09:11:59 +00:00
|
|
|
if (hr != S_OK)
|
|
|
|
hr = CFSExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
2013-12-19 12:51:32 +00:00
|
|
|
else if (IsEqualIID (riid, IID_IDropTarget))
|
|
|
|
{
|
|
|
|
/* only interested in attempting to bind to shell folders, not files (except exe), so if we fail, rebind to root */
|
2014-04-28 21:59:02 +00:00
|
|
|
if (cidl != 1 || FAILED(hr = this->_GetDropTarget(apidl[0], (LPVOID*) &pObj)))
|
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
hr = CFSDropTarget_CreateInstance(m_sPathTarget, riid, (LPVOID*) &pObj);
|
2014-04-28 21:59:02 +00:00
|
|
|
}
|
2013-12-19 12:51:32 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
else
|
|
|
|
hr = E_NOINTERFACE;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && !pObj)
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*ppvOut = pObj;
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("(%p)->hr=0x%08x\n", this, hr);
|
2011-05-15 15:55:49 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-12-21 02:43:36 +00:00
|
|
|
static const WCHAR AdvancedW[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
|
2011-12-18 21:54:04 +00:00
|
|
|
static const WCHAR HideFileExtW[] = L"HideFileExt";
|
|
|
|
static const WCHAR NeverShowExtW[] = L"NeverShowExt";
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SHELL_FS_HideExtension [Internal]
|
|
|
|
*
|
|
|
|
* Query the registry if the filename extension of a given path should be
|
|
|
|
* hidden.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* szPath [I] Relative or absolute path of a file
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE, if the filename's extension should be hidden
|
|
|
|
* FALSE, otherwise.
|
|
|
|
*/
|
|
|
|
BOOL SHELL_FS_HideExtension(LPWSTR szPath)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwData;
|
|
|
|
DWORD dwDataSize = sizeof (DWORD);
|
|
|
|
BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
|
|
|
|
|
|
|
|
if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
|
|
|
|
if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize))
|
|
|
|
doHide = dwData;
|
|
|
|
RegCloseKey (hKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!doHide) {
|
|
|
|
LPWSTR ext = PathFindExtensionW(szPath);
|
|
|
|
|
|
|
|
if (*ext != '\0') {
|
|
|
|
WCHAR classname[MAX_PATH];
|
|
|
|
LONG classlen = sizeof(classname);
|
|
|
|
|
|
|
|
if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen))
|
|
|
|
if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) {
|
|
|
|
if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL))
|
|
|
|
doHide = TRUE;
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return doHide;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SHELL_FS_ProcessDisplayFilename(LPWSTR szPath, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
|
|
|
|
if (!(dwFlags & SHGDN_FORPARSING) &&
|
2013-12-19 12:51:32 +00:00
|
|
|
((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
|
|
|
|
if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
|
|
|
|
PathRemoveExtensionW(szPath);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::GetDisplayNameOf
|
2011-05-15 15:55:49 +00:00
|
|
|
* Retrieves the display name for the specified file object or subfolder
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* LPCITEMIDLIST pidl, //[in ] complex pidl to item
|
|
|
|
* DWORD dwFlags, //[in ] SHGNO formatting flags
|
|
|
|
* LPSTRRET lpName) //[out] Returned display name
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* if the name is in the pidl the ret value should be a STRRET_OFFSET
|
|
|
|
*/
|
|
|
|
|
2014-08-15 10:38:11 +00:00
|
|
|
HRESULT WINAPI CFSFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl,
|
2011-12-17 22:53:44 +00:00
|
|
|
DWORD dwFlags, LPSTRRET strRet)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2017-06-11 10:39:55 +00:00
|
|
|
if (!strRet)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2015-08-31 11:28:24 +00:00
|
|
|
/* If it is a complex pidl, let the child handle it */
|
|
|
|
if (!_ILIsPidlSimple (pidl)) /* complex pidl */
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2015-08-31 11:28:24 +00:00
|
|
|
return SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, strRet);
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
2017-06-11 10:39:55 +00:00
|
|
|
else if (pidl && !pidl->mkid.cb) /* empty pidl */
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2015-08-31 11:28:24 +00:00
|
|
|
/* If it is an empty pidl return only the path of the folder */
|
|
|
|
if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
|
|
|
|
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget)
|
2011-12-18 21:54:04 +00:00
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
return SHSetStrRet(strRet, m_sPathTarget);
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
2015-08-31 11:28:24 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
|
|
|
|
if (!pszPath)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
|
|
|
|
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget)
|
2015-08-31 11:28:24 +00:00
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
lstrcpynW(pszPath, m_sPathTarget, MAX_PATH);
|
2015-08-31 11:28:24 +00:00
|
|
|
PathAddBackslashW(pszPath);
|
|
|
|
len = wcslen(pszPath);
|
|
|
|
}
|
|
|
|
_ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len);
|
|
|
|
if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
|
|
|
|
|
|
|
|
strRet->uType = STRRET_WSTR;
|
|
|
|
strRet->pOleStr = pszPath;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE ("-- (%p)->(%s)\n", this, strRet->uType == STRRET_CSTR ? strRet->cStr : debugstr_w(strRet->pOleStr));
|
2015-08-31 11:28:24 +00:00
|
|
|
return S_OK;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::SetNameOf
|
2011-05-15 15:55:49 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2011-12-18 21:54:04 +00:00
|
|
|
HRESULT WINAPI CFSFolder::SetNameOf(
|
|
|
|
HWND hwndOwner,
|
2014-08-15 10:38:11 +00:00
|
|
|
PCUITEMID_CHILD pidl,
|
2011-12-18 21:54:04 +00:00
|
|
|
LPCOLESTR lpName,
|
|
|
|
DWORD dwFlags,
|
2014-08-15 10:38:11 +00:00
|
|
|
PITEMID_CHILD *pPidlOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
WCHAR szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1];
|
|
|
|
BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl));
|
|
|
|
|
|
|
|
TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", this, hwndOwner, pidl,
|
2011-12-17 22:53:44 +00:00
|
|
|
debugstr_w (lpName), dwFlags, pPidlOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-08-21 12:18:46 +00:00
|
|
|
FileStructW* pDataW = _ILGetFileStructW(pidl);
|
|
|
|
if (!pDataW)
|
|
|
|
{
|
|
|
|
ERR("Got garbage pidl\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
/* build source path */
|
2019-12-04 20:35:25 +00:00
|
|
|
PathCombineW(szSrc, m_sPathTarget, pDataW->wszName);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/* build destination path */
|
2017-08-21 12:18:46 +00:00
|
|
|
if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER)
|
2019-12-04 20:35:25 +00:00
|
|
|
PathCombineW(szDest, m_sPathTarget, lpName);
|
2017-08-21 12:18:46 +00:00
|
|
|
else
|
2011-05-15 15:55:49 +00:00
|
|
|
lstrcpynW(szDest, lpName, MAX_PATH);
|
|
|
|
|
|
|
|
if(!(dwFlags & SHGDN_FORPARSING) && SHELL_FS_HideExtension(szSrc)) {
|
|
|
|
WCHAR *ext = PathFindExtensionW(szSrc);
|
|
|
|
if(*ext != '\0') {
|
|
|
|
INT len = wcslen(szDest);
|
|
|
|
lstrcpynW(szDest + len, ext, MAX_PATH - len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest));
|
2017-08-21 12:18:46 +00:00
|
|
|
if (!wcscmp(szSrc, szDest))
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
/* src and destination is the same */
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if (pPidlOut)
|
|
|
|
hr = _ILCreateFromPathW(szDest, pPidlOut);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (MoveFileW (szSrc, szDest))
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (pPidlOut)
|
|
|
|
hr = _ILCreateFromPathW(szDest, pPidlOut);
|
|
|
|
|
|
|
|
SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM,
|
2011-12-17 22:53:44 +00:00
|
|
|
SHCNF_PATHW, szSrc, szDest);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::GetDefaultSearchGUID(GUID * pguid)
|
|
|
|
{
|
|
|
|
FIXME ("(%p)\n", this);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::EnumSearches(IEnumExtraSearch ** ppenum)
|
|
|
|
{
|
|
|
|
FIXME ("(%p)\n", this);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::GetDefaultColumn(DWORD dwRes,
|
2011-12-17 22:53:44 +00:00
|
|
|
ULONG * pSort, ULONG * pDisplay)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
TRACE ("(%p)\n", this);
|
|
|
|
|
|
|
|
if (pSort)
|
|
|
|
*pSort = 0;
|
|
|
|
if (pDisplay)
|
|
|
|
*pDisplay = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::GetDefaultColumnState(UINT iColumn,
|
2011-12-17 22:53:44 +00:00
|
|
|
DWORD * pcsFlags)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
TRACE ("(%p)\n", this);
|
|
|
|
|
|
|
|
if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pcsFlags = GenericSFHeader[iColumn].pcsFlags;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-15 10:38:11 +00:00
|
|
|
HRESULT WINAPI CFSFolder::GetDetailsEx(PCUITEMID_CHILD pidl,
|
2011-12-17 22:53:44 +00:00
|
|
|
const SHCOLUMNID * pscid, VARIANT * pv)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
FIXME ("(%p)\n", this);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-08-15 10:38:11 +00:00
|
|
|
HRESULT WINAPI CFSFolder::GetDetailsOf(PCUITEMID_CHILD pidl,
|
2011-12-17 22:53:44 +00:00
|
|
|
UINT iColumn, SHELLDETAILS * psd)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
|
|
|
|
TRACE ("(%p)->(%p %i %p)\n", this, pidl, iColumn, psd);
|
|
|
|
|
|
|
|
if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!pidl)
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
/* the header titles */
|
|
|
|
psd->fmt = GenericSFHeader[iColumn].fmt;
|
|
|
|
psd->cxChar = GenericSFHeader[iColumn].cxChar;
|
2016-04-30 14:05:10 +00:00
|
|
|
return SHSetStrRet(&psd->str, GenericSFHeader[iColumn].colnameid);
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
hr = S_OK;
|
|
|
|
psd->str.uType = STRRET_CSTR;
|
|
|
|
/* the data from the pidl */
|
2011-12-18 21:54:04 +00:00
|
|
|
switch (iColumn)
|
|
|
|
{
|
2011-12-17 22:53:44 +00:00
|
|
|
case 0: /* name */
|
2017-06-12 18:38:26 +00:00
|
|
|
hr = GetDisplayNameOf (pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
|
2011-12-17 22:53:44 +00:00
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 1: /* FIXME: comments */
|
|
|
|
psd->str.cStr[0] = 0;
|
2011-12-17 22:53:44 +00:00
|
|
|
break;
|
|
|
|
case 2: /* type */
|
2011-12-18 21:54:04 +00:00
|
|
|
_ILGetFileType(pidl, psd->str.cStr, MAX_PATH);
|
2011-12-17 22:53:44 +00:00
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 3: /* size */
|
|
|
|
_ILGetFileSize(pidl, psd->str.cStr, MAX_PATH);
|
|
|
|
break;
|
|
|
|
case 4: /* date */
|
2011-12-18 21:54:04 +00:00
|
|
|
_ILGetFileDate(pidl, psd->str.cStr, MAX_PATH);
|
2011-12-17 22:53:44 +00:00
|
|
|
break;
|
2017-06-12 18:38:26 +00:00
|
|
|
case 5: /* attributes */
|
2011-12-18 21:54:04 +00:00
|
|
|
_ILGetFileAttributes(pidl, psd->str.cStr, MAX_PATH);
|
2011-12-17 22:53:44 +00:00
|
|
|
break;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::MapColumnToSCID (UINT column,
|
2011-12-17 22:53:44 +00:00
|
|
|
SHCOLUMNID * pscid)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
FIXME ("(%p)\n", this);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::GetClassID
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::GetClassID(CLSID * lpClassId)
|
|
|
|
{
|
|
|
|
TRACE ("(%p)\n", this);
|
|
|
|
|
|
|
|
if (!lpClassId)
|
|
|
|
return E_POINTER;
|
2011-12-18 21:54:04 +00:00
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
*lpClassId = *m_pclsid;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::Initialize
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
2019-12-04 20:35:25 +00:00
|
|
|
* m_sPathTarget is not set. Don't know how to handle in a non rooted environment.
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
2019-09-22 14:38:06 +00:00
|
|
|
HRESULT WINAPI CFSFolder::Initialize(PCIDLIST_ABSOLUTE pidl)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
WCHAR wszTemp[MAX_PATH];
|
|
|
|
|
|
|
|
TRACE ("(%p)->(%p)\n", this, pidl);
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
SHFree(m_pidlRoot); /* free the old pidl */
|
|
|
|
m_pidlRoot = ILClone (pidl); /* set my pidl */
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
SHFree (m_sPathTarget);
|
|
|
|
m_sPathTarget = NULL;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/* set my path */
|
2011-12-18 21:54:04 +00:00
|
|
|
if (SHGetPathFromIDListW (pidl, wszTemp))
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
int len = wcslen(wszTemp);
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!m_sPathTarget)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_OUTOFMEMORY;
|
2019-12-04 20:35:25 +00:00
|
|
|
memcpy(m_sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
TRACE ("--(%p)->(%s)\n", this, debugstr_w(m_sPathTarget));
|
2011-05-15 15:55:49 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::GetCurFolder
|
2011-05-15 15:55:49 +00:00
|
|
|
*/
|
2019-09-10 10:24:11 +00:00
|
|
|
HRESULT WINAPI CFSFolder::GetCurFolder(PIDLIST_ABSOLUTE * pidl)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
TRACE ("(%p)->(%p)\n", this, pidl);
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!pidl)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
*pidl = ILClone(m_pidlRoot);
|
2011-05-15 15:55:49 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2011-12-18 21:54:04 +00:00
|
|
|
* CFSFolder::InitializeEx
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* FIXME: error handling
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CFSFolder::InitializeEx(IBindCtx * pbc, LPCITEMIDLIST pidlRootx,
|
2011-12-17 22:53:44 +00:00
|
|
|
const PERSIST_FOLDER_TARGET_INFO * ppfti)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
WCHAR wszTemp[MAX_PATH];
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("(%p)->(%p,%p,%p)\n", this, pbc, pidlRootx, ppfti);
|
2011-05-15 15:55:49 +00:00
|
|
|
if (ppfti)
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("--%p %s %s 0x%08x 0x%08x\n",
|
|
|
|
ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName),
|
|
|
|
debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes,
|
|
|
|
ppfti->csidl);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
pdump (pidlRootx);
|
|
|
|
if (ppfti && ppfti->pidlTargetFolder)
|
2011-12-18 21:54:04 +00:00
|
|
|
pdump(ppfti->pidlTargetFolder);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
if (m_pidlRoot)
|
|
|
|
__SHFreeAndNil(&m_pidlRoot); /* free the old */
|
|
|
|
if (m_sPathTarget)
|
|
|
|
__SHFreeAndNil(&m_sPathTarget);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Root path and pidl
|
|
|
|
*/
|
2019-12-04 20:35:25 +00:00
|
|
|
m_pidlRoot = ILClone(pidlRootx);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the target folder is spezified in csidl OR pidlTargetFolder OR
|
|
|
|
* szTargetParsingName
|
|
|
|
*/
|
2011-12-18 21:54:04 +00:00
|
|
|
if (ppfti)
|
|
|
|
{
|
|
|
|
if (ppfti->csidl != -1)
|
|
|
|
{
|
|
|
|
if (SHGetSpecialFolderPathW(0, wszTemp, ppfti->csidl,
|
|
|
|
ppfti->csidl & CSIDL_FLAG_CREATE)) {
|
2011-05-15 15:55:49 +00:00
|
|
|
int len = wcslen(wszTemp);
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!m_sPathTarget)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_OUTOFMEMORY;
|
2019-12-04 20:35:25 +00:00
|
|
|
memcpy(m_sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
|
|
|
else if (ppfti->szTargetParsingName[0])
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
int len = wcslen(ppfti->szTargetParsingName);
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!m_sPathTarget)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_OUTOFMEMORY;
|
2019-12-04 20:35:25 +00:00
|
|
|
memcpy(m_sPathTarget, ppfti->szTargetParsingName,
|
2011-05-15 15:55:49 +00:00
|
|
|
(len + 1) * sizeof(WCHAR));
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
|
|
|
else if (ppfti->pidlTargetFolder)
|
|
|
|
{
|
|
|
|
if (SHGetPathFromIDListW(ppfti->pidlTargetFolder, wszTemp))
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
int len = wcslen(wszTemp);
|
2019-12-04 20:35:25 +00:00
|
|
|
m_sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!m_sPathTarget)
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_OUTOFMEMORY;
|
2019-12-04 20:35:25 +00:00
|
|
|
memcpy(m_sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
TRACE("--(%p)->(target=%s)\n", this, debugstr_w(m_sPathTarget));
|
|
|
|
pdump(m_pidlRoot);
|
|
|
|
return (m_sPathTarget) ? S_OK : E_FAIL;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO * ppfti)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
FIXME("(%p)->(%p)\n", this, ppfti);
|
|
|
|
ZeroMemory(ppfti, sizeof (*ppfti));
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
HRESULT CFSFolder::_CreateExtensionUIObject(PCUIDLIST_RELATIVE pidl, REFIID riid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
static const WCHAR formatW[] = {'S','h','e','l','l','E','x','\\',
|
|
|
|
'{','%','0','8','x','-','%','0','4','x','-','%','0','4','x','-',
|
|
|
|
'%','0','2','x','%','0','2','x','-','%','0','2','x','%','0','2','x',
|
|
|
|
'%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x','}',0};
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
|
|
|
|
sprintfW(buf, formatW, riid.Data1, riid.Data2, riid.Data3,
|
|
|
|
riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3],
|
|
|
|
riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7]);
|
|
|
|
|
|
|
|
CLSID clsid;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = GetCLSIDForFileType(pidl, buf, &clsid);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = _CreateShellExtInstance(&clsid, pidl, riid, ppvOut);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CFSFolder::_GetDropTarget(LPCITEMIDLIST pidl, LPVOID *ppvOut)
|
|
|
|
{
|
2014-03-15 13:59:22 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("CFSFolder::_GetDropTarget entered\n");
|
|
|
|
|
2016-05-03 13:47:16 +00:00
|
|
|
if (_ILIsFolder (pidl))
|
2016-07-29 12:56:06 +00:00
|
|
|
{
|
|
|
|
CComPtr<IShellFolder> psfChild;
|
|
|
|
hr = this->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return psfChild->CreateViewObject(NULL, IID_IDropTarget, ppvOut);
|
|
|
|
}
|
2014-03-15 13:59:22 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
CLSID clsid;
|
|
|
|
hr = GetCLSIDForFileType(pidl, L"shellex\\DropHandler", &clsid);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return hr;
|
2014-03-15 13:59:22 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
hr = _CreateShellExtInstance(&clsid, pidl, IID_IDropTarget, ppvOut);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return S_FALSE;
|
2014-03-15 13:59:22 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
return S_OK;
|
2014-03-15 13:59:22 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
HRESULT CFSFolder::_GetIconHandler(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
|
2014-03-15 13:59:22 +00:00
|
|
|
{
|
2017-08-18 09:11:59 +00:00
|
|
|
CLSID clsid;
|
2014-03-15 13:59:22 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
hr = GetCLSIDForFileType(pidl, L"shellex\\IconHandler", &clsid);
|
|
|
|
if (hr != S_OK)
|
2017-02-20 20:13:22 +00:00
|
|
|
return hr;
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
hr = _CreateShellExtInstance(&clsid, pidl, riid, ppvOut);
|
2017-02-20 20:13:22 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
2017-08-18 09:11:59 +00:00
|
|
|
return S_FALSE;
|
2017-02-20 20:13:22 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2014-03-15 13:59:22 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
HRESULT CFSFolder::_CreateShellExtInstance(const CLSID *pclsid, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
|
2014-03-15 13:59:22 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2017-08-18 09:11:59 +00:00
|
|
|
WCHAR wszPath[MAX_PATH];
|
2014-03-15 13:59:22 +00:00
|
|
|
|
2017-08-18 09:11:59 +00:00
|
|
|
FileStructW* pDataW = _ILGetFileStructW(pidl);
|
|
|
|
if (!pDataW)
|
2014-03-15 13:59:22 +00:00
|
|
|
{
|
2017-08-18 09:11:59 +00:00
|
|
|
ERR("Got garbage pidl\n");
|
|
|
|
return E_INVALIDARG;
|
2014-03-15 13:59:22 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 20:35:25 +00:00
|
|
|
PathCombineW(wszPath, m_sPathTarget, pDataW->wszName);
|
2017-08-18 09:11:59 +00:00
|
|
|
|
|
|
|
CComPtr<IPersistFile> pp;
|
|
|
|
hr = SHCoCreateInstance(NULL, pclsid, NULL, IID_PPV_ARG(IPersistFile, &pp));
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
pp->Load(wszPath, 0);
|
|
|
|
|
|
|
|
hr = pp->QueryInterface(riid, ppvOut);
|
2014-03-15 13:59:22 +00:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("Failed to query for interface IID_IShellExtInit hr %x pclsid %s\n", hr, wine_dbgstr_guid(pclsid));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return hr;
|
2016-11-17 14:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2016-11-29 15:38:55 +00:00
|
|
|
if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
/* no data object means no selection */
|
|
|
|
if (!pdtobj)
|
|
|
|
{
|
2017-08-14 15:25:58 +00:00
|
|
|
if (uMsg == DFM_INVOKECOMMAND && wParam == 0)
|
2016-11-29 15:38:55 +00:00
|
|
|
{
|
2019-12-04 20:35:25 +00:00
|
|
|
PUITEMID_CHILD pidlChild = ILClone(ILFindLastID(m_pidlRoot));
|
|
|
|
LPITEMIDLIST pidlParent = ILClone(m_pidlRoot);
|
2016-11-29 15:38:55 +00:00
|
|
|
ILRemoveLastID(pidlParent);
|
2019-12-04 20:35:25 +00:00
|
|
|
HRESULT hr = SH_ShowPropertiesDialog(m_sPathTarget, pidlParent, &pidlChild);
|
2016-11-29 15:38:55 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("SH_ShowPropertiesDialog failed\n");
|
|
|
|
ILFree(pidlChild);
|
|
|
|
ILFree(pidlParent);
|
|
|
|
}
|
|
|
|
else if (uMsg == DFM_MERGECONTEXTMENU)
|
|
|
|
{
|
|
|
|
QCMINFO *pqcminfo = (QCMINFO *)lParam;
|
2017-08-14 15:25:58 +00:00
|
|
|
HMENU hpopup = CreatePopupMenu();
|
|
|
|
_InsertMenuItemW(hpopup, 0, TRUE, 0, MFT_STRING, MAKEINTRESOURCEW(IDS_PROPERTIES), MFS_ENABLED);
|
|
|
|
Shell_MergeMenus(pqcminfo->hmenu, hpopup, pqcminfo->indexMenu++, pqcminfo->idCmdFirst, pqcminfo->idCmdLast, MM_ADDSEPARATOR);
|
|
|
|
DestroyMenu(hpopup);
|
2016-11-29 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-17 14:35:19 +00:00
|
|
|
if (uMsg != DFM_INVOKECOMMAND || wParam != DFM_CMD_PROPERTIES)
|
|
|
|
return S_OK;
|
|
|
|
|
2018-07-08 15:01:12 +00:00
|
|
|
return Shell_DefaultContextMenuCallBack(this, pdtobj);
|
2016-11-17 14:35:19 +00:00
|
|
|
}
|
2019-04-04 22:59:35 +00:00
|
|
|
|
|
|
|
static HBITMAP DoLoadPicture(LPCWSTR pszFileName)
|
|
|
|
{
|
|
|
|
// create stream from file
|
|
|
|
HRESULT hr;
|
|
|
|
CComPtr<IStream> pStream;
|
|
|
|
hr = SHCreateStreamOnFileEx(pszFileName, STGM_READ, FILE_ATTRIBUTE_NORMAL,
|
|
|
|
FALSE, NULL, &pStream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// load the picture
|
|
|
|
HBITMAP hbm = NULL;
|
|
|
|
CComPtr<IPicture> pPicture;
|
|
|
|
OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
|
|
|
|
|
|
|
|
// get the bitmap handle
|
|
|
|
if (pPicture)
|
|
|
|
{
|
|
|
|
pPicture->get_Handle((OLE_HANDLE *)&hbm);
|
|
|
|
|
|
|
|
// copy the bitmap handle
|
|
|
|
hbm = (HBITMAP)CopyImage(hbm, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hbm;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::GetCustomViewInfo(ULONG unknown, SFVM_CUSTOMVIEWINFO_DATA *data)
|
|
|
|
{
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
if (data->cbSize != sizeof(*data))
|
|
|
|
{
|
|
|
|
// NOTE: You have to set the cbData member before SFVM_GET_CUSTOMVIEWINFO call.
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->hbmBack = NULL;
|
|
|
|
data->clrText = CLR_INVALID;
|
|
|
|
data->clrTextBack = CLR_INVALID;
|
|
|
|
|
|
|
|
WCHAR szPath[MAX_PATH], szIniFile[MAX_PATH];
|
|
|
|
|
|
|
|
// does the folder exists?
|
2019-12-04 20:35:25 +00:00
|
|
|
if (!SHGetPathFromIDListW(m_pidlRoot, szPath) || !PathIsDirectoryW(szPath))
|
2019-04-04 22:59:35 +00:00
|
|
|
{
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't use custom view in network path for security
|
|
|
|
if (PathIsNetworkPath(szPath))
|
|
|
|
{
|
|
|
|
return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// build the ini file path
|
|
|
|
StringCchCopyW(szIniFile, _countof(szIniFile), szPath);
|
|
|
|
PathAppend(szIniFile, L"desktop.ini");
|
|
|
|
|
|
|
|
static LPCWSTR TheGUID = L"{BE098140-A513-11D0-A3A4-00C04FD706EC}";
|
|
|
|
static LPCWSTR Space = L" \t\n\r\f\v";
|
|
|
|
|
|
|
|
// get info from ini file
|
|
|
|
WCHAR szImage[MAX_PATH], szText[64];
|
|
|
|
|
|
|
|
// load the image
|
|
|
|
szImage[0] = UNICODE_NULL;
|
|
|
|
GetPrivateProfileStringW(TheGUID, L"IconArea_Image", L"", szImage, _countof(szImage), szIniFile);
|
|
|
|
if (szImage[0])
|
|
|
|
{
|
|
|
|
StrTrimW(szImage, Space);
|
|
|
|
if (PathIsRelativeW(szImage))
|
|
|
|
{
|
|
|
|
PathAppendW(szPath, szImage);
|
|
|
|
StringCchCopyW(szImage, _countof(szImage), szPath);
|
|
|
|
}
|
|
|
|
data->hbmBack = DoLoadPicture(szImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
// load the text color
|
|
|
|
szText[0] = UNICODE_NULL;
|
|
|
|
GetPrivateProfileStringW(TheGUID, L"IconArea_Text", L"", szText, _countof(szText), szIniFile);
|
|
|
|
if (szText[0])
|
|
|
|
{
|
|
|
|
StrTrimW(szText, Space);
|
|
|
|
|
|
|
|
LPWSTR pchEnd = NULL;
|
|
|
|
COLORREF cr = (wcstol(szText, &pchEnd, 0) & 0xFFFFFF);
|
|
|
|
|
|
|
|
if (pchEnd && !*pchEnd)
|
|
|
|
data->clrText = cr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// load the text background color
|
|
|
|
szText[0] = UNICODE_NULL;
|
|
|
|
GetPrivateProfileStringW(TheGUID, L"IconArea_TextBackground", L"", szText, _countof(szText), szIniFile);
|
|
|
|
if (szText[0])
|
|
|
|
{
|
|
|
|
StrTrimW(szText, Space);
|
|
|
|
|
|
|
|
LPWSTR pchEnd = NULL;
|
|
|
|
COLORREF cr = (wcstol(szText, &pchEnd, 0) & 0xFFFFFF);
|
|
|
|
|
|
|
|
if (pchEnd && !*pchEnd)
|
|
|
|
data->clrTextBack = cr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->hbmBack != NULL || data->clrText != CLR_INVALID || data->clrTextBack != CLR_INVALID)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI CFSFolder::MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HRESULT hr = E_NOTIMPL;
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case SFVM_GET_CUSTOMVIEWINFO:
|
|
|
|
hr = GetCustomViewInfo((ULONG)wParam, (SFVM_CUSTOMVIEWINFO_DATA *)lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|