https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4cdcea5e65326cbea77458a3e9daa335d2e530b7

commit 4cdcea5e65326cbea77458a3e9daa335d2e530b7
Author:     Mark Jansen <[email protected]>
AuthorDate: Wed Apr 19 20:30:24 2023 +0200
Commit:     Mark Jansen <[email protected]>
CommitDate: Wed Apr 26 22:50:11 2023 +0200

    [SHELL32] Implement SHQueryRecycleBinW
---
 dll/win32/shell32/folders/CRecycleBin.cpp      | 36 +++++++++++++++++++++++---
 dll/win32/shell32/shellrecyclebin/recyclebin.c | 12 ---------
 dll/win32/shell32/shellrecyclebin/recyclebin.h | 11 --------
 3 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp 
b/dll/win32/shell32/folders/CRecycleBin.cpp
index bb44ca3cd6a..6dba39d8c69 100644
--- a/dll/win32/shell32/folders/CRecycleBin.cpp
+++ b/dll/win32/shell32/folders/CRecycleBin.cpp
@@ -415,7 +415,7 @@ HRESULT WINAPI 
CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO l
         BOOL ret = TRUE;
 
         /* restore file */
-        if (lpcmi->lpVerb == MAKEINTRESOURCEA(1)) 
+        if (lpcmi->lpVerb == MAKEINTRESOURCEA(1))
             ret = RestoreFile(Context.hDeletedFile);
         /* delete file */
         else
@@ -1244,10 +1244,10 @@ HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, 
LPSHQUERYRBINFO pSHQueryRB
 
 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO 
pSHQueryRBInfo)
 {
-    FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
+    TRACE("%s, %p\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
 
-    if (!(pszRootPath) || (pszRootPath[0] == 0) ||
-        !(pSHQueryRBInfo) || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO)))
+    if (!pszRootPath || (pszRootPath[0] == 0) ||
+        !pSHQueryRBInfo || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO)))
     {
         return E_INVALIDARG;
     }
@@ -1255,5 +1255,33 @@ HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, 
LPSHQUERYRBINFO pSHQueryR
     pSHQueryRBInfo->i64Size = 0;
     pSHQueryRBInfo->i64NumItems = 0;
 
+    CComPtr<IRecycleBin> spRecycleBin;
+    HRESULT hr;
+    if (FAILED_UNEXPECTEDLY((hr = GetDefaultRecycleBin(pszRootPath, 
&spRecycleBin))))
+        return hr;
+
+    CComPtr<IRecycleBinEnumList> spEnumList;
+    hr = spRecycleBin->EnumObjects(&spEnumList);
+    if (!SUCCEEDED(hr))
+        return hr;
+
+    while (TRUE)
+    {
+        CComPtr<IRecycleBinFile> spFile;
+        hr = spEnumList->Next(1, &spFile, NULL);
+        if (hr == S_FALSE)
+            return S_OK;
+
+        if (FAILED_UNEXPECTEDLY(hr))
+            return hr;
+
+        ULARGE_INTEGER Size = {};
+        if (FAILED_UNEXPECTEDLY((hr = spFile->GetFileSize(&Size))))
+            return hr;
+
+        pSHQueryRBInfo->i64Size += Size.QuadPart;
+        pSHQueryRBInfo->i64NumItems++;
+    }
+
     return S_OK;
 }
diff --git a/dll/win32/shell32/shellrecyclebin/recyclebin.c 
b/dll/win32/shell32/shellrecyclebin/recyclebin.c
index a6392496012..670e81b6dbf 100644
--- a/dll/win32/shell32/shellrecyclebin/recyclebin.c
+++ b/dll/win32/shell32/shellrecyclebin/recyclebin.c
@@ -376,18 +376,6 @@ cleanup:
     return FALSE;
 }
 
-BOOL WINAPI
-GetRecycleBinDetails(
-    IN LPCWSTR pszVolume OPTIONAL,
-    OUT ULARGE_INTEGER *pulTotalItems,
-    OUT ULARGE_INTEGER *pulTotalSize)
-{
-    pulTotalItems->QuadPart = 0;
-    pulTotalSize->QuadPart = 0;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
-}
-
 BOOL WINAPI
 RestoreFile(
     IN HANDLE hDeletedFile)
diff --git a/dll/win32/shell32/shellrecyclebin/recyclebin.h 
b/dll/win32/shell32/shellrecyclebin/recyclebin.h
index 50c020c839f..f15828a9639 100644
--- a/dll/win32/shell32/shellrecyclebin/recyclebin.h
+++ b/dll/win32/shell32/shellrecyclebin/recyclebin.h
@@ -164,17 +164,6 @@ GetDeletedFileDetailsW(
 #define GetDeletedFileDetails GetDeletedFileDetailsA
 #endif
 
-/* Get details about a whole recycle bin
- * pszVolume:
- * pulTotalItems:
- * pulTotalSize
- */
-BOOL WINAPI
-GetRecycleBinDetails(
-    IN LPCWSTR pszVolume OPTIONAL,
-    OUT ULARGE_INTEGER *pulTotalItems,
-    OUT ULARGE_INTEGER *pulTotalSize);
-
 /* Restores a deleted file
  * hDeletedFile: handle of the deleted file to restore
  * Returns TRUE if operation succeeded, FALSE otherwise.

Reply via email to