https://git.reactos.org/?p=reactos.git;a=commitdiff;h=711f63184915c2e2f12532...
commit 711f63184915c2e2f125325b774f13ccf781887d Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Mon May 11 11:43:07 2020 +0900 Commit: GitHub noreply@github.com CommitDate: Mon May 11 11:43:07 2020 +0900
[SHELL32] Don't hardcode C: drive (#2768)
CORE-13235 --- dll/win32/shell32/folders/CRecycleBin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp b/dll/win32/shell32/folders/CRecycleBin.cpp index a62696a2628..a32c42b621f 100644 --- a/dll/win32/shell32/folders/CRecycleBin.cpp +++ b/dll/win32/shell32/folders/CRecycleBin.cpp @@ -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;