[SHELL32] Don't hardcode C: drive (#2768)

CORE-13235
This commit is contained in:
Katayama Hirofumi MZ 2020-05-11 11:43:07 +09:00 committed by GitHub
parent 9c11be5a3a
commit 711f631849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,13 +191,17 @@ CRecycleBinEnum::~CRecycleBinEnum()
HRESULT WINAPI CRecycleBinEnum::Initialize(DWORD dwFlags)
{
static LPCWSTR szDrive = L"C:\\";
WCHAR szDrive[8];
if (GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)))
PathAddBackslashW(szDrive);
else
StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
if (dwFlags & SHCONTF_NONFOLDERS)
{
TRACE("Starting Enumeration\n");
if (!EnumerateRecycleBinW(szDrive /* FIXME */ , CBEnumRecycleBin, (PVOID)this))
if (!EnumerateRecycleBinW(szDrive, CBEnumRecycleBin, this))
{
WARN("Error: EnumerateCRecycleBinW failed\n");
return E_FAIL;
@ -354,7 +358,7 @@ HRESULT WINAPI CRecycleBinItemContextMenu::QueryContextMenu(HMENU hMenu, UINT in
HRESULT WINAPI CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
SEARCH_CONTEXT Context;
static LPCWSTR szDrive = L"C:\\";
WCHAR szDrive[8];
TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", this, lpcmi, lpcmi->lpVerb, lpcmi->hwnd);
@ -363,6 +367,11 @@ HRESULT WINAPI CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO l
Context.pFileDetails = _ILGetRecycleStruct(apidl);
Context.bFound = FALSE;
if (GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)))
PathAddBackslashW(szDrive);
else
StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
EnumerateRecycleBinW(szDrive, CBSearchRecycleBin, (PVOID)&Context);
if (!Context.bFound)
return E_FAIL;