ReactOS 0.4.16-dev-942-g91fadeb
CRecycleBinCleaner.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: CRecycleBinCleaner implementation
5 * COPYRIGHT: Copyright 2023-2025 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#include "precomp.h"
9
11
12
13CLSID CLSID_RecycleBinCleaner = { 0x5ef4af3a, 0xf726, 0x11d0, { 0xb8, 0xa2, 0x00, 0xc0, 0x4f, 0xc3, 0x09, 0xa4 } };
14
16 public CComObjectRootEx<CComSingleThreadModel>,
17 public CComCoClass<CRecycleBinCleaner, &CLSID_RecycleBinCleaner>,
19{
21
22 void
23 OutputResourceString(DWORD dwResId, _Out_ LPWSTR *ppwszOutput)
24 {
25 CStringW Tmp(MAKEINTRESOURCEW(dwResId));
26 SHStrDupW(Tmp, ppwszOutput);
27 }
28
29public:
30
31 // +IEmptyVolumeCache
33 _In_ HKEY hkRegKey,
34 _In_ LPCWSTR pcwszVolume,
35 _Out_ LPWSTR* ppwszDisplayName,
36 _Out_ LPWSTR* ppwszDescription,
37 _Out_ DWORD* pdwFlags)
38 {
39 if (!pdwFlags)
40 return E_POINTER;
41
42 *pdwFlags = EVCF_HASSETTINGS;
43
46
47 return StringCchCopyW(m_wszVolume, _countof(m_wszVolume), pcwszVolume);
48 }
49
51 _Out_ DWORDLONG* pdwlSpaceUsed,
53 {
54 if (!pdwlSpaceUsed)
55 return E_POINTER;
56
57 SHQUERYRBINFO bin = { sizeof(bin) };
60 {
61 bin.i64Size = 0;
62 }
63 *pdwlSpaceUsed = bin.i64Size;
64 if (picb)
65 {
66 picb->ScanProgress(bin.i64Size, EVCCBF_LASTNOTIFICATION, NULL);
67 }
68
69 return S_OK;
70 }
71
73 _In_ DWORDLONG dwlSpaceToFree,
75 {
76 DWORDLONG dwlPrevious = 0;
77 GetSpaceUsed(&dwlPrevious, NULL);
78
80 if (picb)
81 {
82 picb->PurgeProgress(dwlPrevious, 0, EVCCBF_LASTNOTIFICATION, NULL);
83 }
84
85 return S_OK;
86 }
87
90 {
92 HRESULT hr;
94 return hr;
95
96 SHELLEXECUTEINFOW seei = {sizeof(seei)};
97 seei.hwnd = hwnd;
98 seei.lpVerb = L"open";
99 seei.nShow = SW_SHOWNORMAL;
100 seei.fMask = SEE_MASK_IDLIST;
101 seei.lpIDList = pidl;
102 ShellExecuteExW(&seei);
103
104 return S_OK;
105 }
106
108 _Out_ DWORD* pdwFlags)
109 {
110 if (!pdwFlags)
111 return E_POINTER;
112
113 *pdwFlags = 0;
114
115 return S_OK;
116 }
117 // -IEmptyVolumeCache
118
119
120 // +IEmptyVolumeCache2
122 _In_ HKEY hkRegKey,
123 _In_ LPCWSTR pcwszVolume,
124 _In_ LPCWSTR pcwszKeyName,
125 _Out_ LPWSTR* ppwszDisplayName,
126 _Out_ LPWSTR* ppwszDescription,
127 _Out_ LPWSTR* ppwszBtnText,
128 _Out_ DWORD* pdwFlags)
129 {
131
132 return Initialize(hkRegKey, pcwszVolume, ppwszDisplayName, ppwszDescription, pdwFlags);
133 }
134 // -IEmptyVolumeCache2
135
136
140
142 COM_INTERFACE_ENTRY_IID(IID_IEmptyVolumeCache2, IEmptyVolumeCache2)
143 COM_INTERFACE_ENTRY_IID(IID_IEmptyVolumeCache, IEmptyVolumeCache)
146};
147
148
CLSID CLSID_RecycleBinCleaner
HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3408
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2018
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define OBJECT_ENTRY_AUTO(clsid, class)
Definition: atlcom.h:707
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:651
#define DECLARE_REGISTRY_RESOURCEID(x)
Definition: atlcom.h:645
#define END_COM_MAP()
Definition: atlcom.h:592
static struct _PeImage bin
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define L(x)
Definition: ntvdm.h:50
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define SHERB_NOSOUND
Definition: shellapi.h:399
#define SHERB_NOPROGRESSUI
Definition: shellapi.h:398
#define SHERB_NOCONFIRMATION
Definition: shellapi.h:397
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2452
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_BITBUCKET
Definition: shlobj.h:2191
#define IDS_RECYCLE_CLEANER_DESCRIPTION
Definition: shresdef.h:291
#define IDS_RECYCLE_CLEANER_DISPLAYNAME
Definition: shresdef.h:290
#define IDS_RECYCLE_CLEANER_BUTTON_TEXT
Definition: shresdef.h:292
#define IDR_RECYCLEBINCLEANER
Definition: shresdef.h:926
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STDMETHODIMP ShowProperties(_In_ HWND hwnd)
STDMETHODIMP Deactivate(_Out_ DWORD *pdwFlags)
STDMETHODIMP Initialize(_In_ HKEY hkRegKey, _In_ LPCWSTR pcwszVolume, _Out_ LPWSTR *ppwszDisplayName, _Out_ LPWSTR *ppwszDescription, _Out_ DWORD *pdwFlags)
STDMETHODIMP Purge(_In_ DWORDLONG dwlSpaceToFree, _In_opt_ IEmptyVolumeCacheCallBack *picb)
STDMETHODIMP InitializeEx(_In_ HKEY hkRegKey, _In_ LPCWSTR pcwszVolume, _In_ LPCWSTR pcwszKeyName, _Out_ LPWSTR *ppwszDisplayName, _Out_ LPWSTR *ppwszDescription, _Out_ LPWSTR *ppwszBtnText, _Out_ DWORD *pdwFlags)
void OutputResourceString(DWORD dwResId, _Out_ LPWSTR *ppwszOutput)
STDMETHODIMP GetSpaceUsed(_Out_ DWORDLONG *pdwlSpaceUsed, _In_opt_ IEmptyVolumeCacheCallBack *picb)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define E_POINTER
Definition: winerror.h:2365
#define SW_SHOWNORMAL
Definition: winuser.h:773
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static void Initialize()
Definition: xlate.c:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185