ReactOS 0.4.15-dev-8100-g1887773
CRecycleBin.cpp File Reference
#include <precomp.h>
#include <mmsystem.h>
#include <ntquery.h>
Include dependency graph for CRecycleBin.cpp:

Go to the source code of this file.

Classes

struct  columninfo
 
struct  _SEARCH_CONTEXT
 
class  CRecycleBinEnum
 
class  CRecycleBinItemContextMenu
 

Macros

#define COLUMN_NAME   0
 
#define COLUMN_DELFROM   1
 
#define COLUMN_DATEDEL   2
 
#define COLUMN_SIZE   3
 
#define COLUMN_TYPE   4
 
#define COLUMN_MTIME   5
 
#define COLUMNS_COUNT   6
 

Typedefs

typedef struct _SEARCH_CONTEXT SEARCH_CONTEXT
 
typedef struct _SEARCH_CONTEXTPSEARCH_CONTEXT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (CRecycleBin)
 
BOOL WINAPI CBSearchRecycleBin (IN PVOID Context, IN HDELFILE hDeletedFile)
 
static PIDLRecycleStruct * _ILGetRecycleStruct (LPCITEMIDLIST pidl)
 
HRESULT CRecyclerExtractIcon_CreateInstance (LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
 
static LPITEMIDLIST _ILCreateRecycleItem (PDELETED_FILE_DETAILS_W pFileDetails)
 
PDELETED_FILE_DETAILS_W UnpackDetailsFromPidl (LPCITEMIDLIST pidl)
 
static HRESULT FormatDateTime (LPWSTR buffer, int size, FILETIME *ft)
 
BOOL TRASH_CanTrashFile (LPCWSTR wszPath)
 
BOOL TRASH_TrashFile (LPCWSTR wszPath)
 
static void TRASH_PlayEmptyRecycleBinSound ()
 
EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon (void)
 
HRESULT WINAPI SHEmptyRecycleBinA (HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
 
HRESULT WINAPI SHEmptyRecycleBinW (HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
 
HRESULT WINAPI SHQueryRecycleBinA (LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
 
HRESULT WINAPI SHQueryRecycleBinW (LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
 

Variables

static const columninfo RecycleBinColumns []
 

Macro Definition Documentation

◆ COLUMN_DATEDEL

#define COLUMN_DATEDEL   2

Definition at line 54 of file CRecycleBin.cpp.

◆ COLUMN_DELFROM

#define COLUMN_DELFROM   1

Definition at line 53 of file CRecycleBin.cpp.

◆ COLUMN_MTIME

#define COLUMN_MTIME   5

Definition at line 57 of file CRecycleBin.cpp.

◆ COLUMN_NAME

#define COLUMN_NAME   0

Definition at line 52 of file CRecycleBin.cpp.

◆ COLUMN_SIZE

#define COLUMN_SIZE   3

Definition at line 55 of file CRecycleBin.cpp.

◆ COLUMN_TYPE

#define COLUMN_TYPE   4

Definition at line 56 of file CRecycleBin.cpp.

◆ COLUMNS_COUNT

#define COLUMNS_COUNT   6

Definition at line 59 of file CRecycleBin.cpp.

Typedef Documentation

◆ PSEARCH_CONTEXT

◆ SEARCH_CONTEXT

Function Documentation

◆ _ILCreateRecycleItem()

static LPITEMIDLIST _ILCreateRecycleItem ( PDELETED_FILE_DETAILS_W  pFileDetails)
static

Definition at line 251 of file CRecycleBin.cpp.

252{
253 PIDLDATA tmp;
254 LPITEMIDLIST pidl;
255 PIDLRecycleStruct * p;
256 int size0 = (char*)&tmp.u.crecycle.szName - (char*)&tmp.u.crecycle;
257 int size = size0;
258
259 tmp.type = 0x00;
260 size += (wcslen(pFileDetails->FileName) + 1) * sizeof(WCHAR);
261
262 pidl = (LPITEMIDLIST)SHAlloc(size + 4);
263 if (!pidl)
264 return pidl;
265
266 pidl->mkid.cb = size + 2;
267 memcpy(pidl->mkid.abID, &tmp, 2 + size0);
268
269 p = &((PIDLDATA*)pidl->mkid.abID)->u.crecycle;
270 RtlCopyMemory(p, pFileDetails, sizeof(DELETED_FILE_DETAILS_W));
271 wcscpy(p->szName, pFileDetails->FileName);
272 *(WORD*)((char*)pidl + (size + 2)) = 0;
273 return pidl;
274}
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
GLfloat GLfloat p
Definition: glext.h:8902
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
WCHAR FileName[ANY_SIZE]
Definition: recyclebin.h:40
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CRecycleBinEnum::CBEnumRecycleBin().

◆ _ILGetRecycleStruct()

static PIDLRecycleStruct * _ILGetRecycleStruct ( LPCITEMIDLIST  pidl)
static

Definition at line 206 of file CRecycleBin.cpp.

207{
209
210 if (pdata && pdata->type == 0x00)
211 return (PIDLRecycleStruct*) & (pdata->u.crecycle);
212
213 return NULL;
214}
#define NULL
Definition: types.h:112
static PROTOCOLDATA * pdata
Definition: protocol.c:158
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2218

Referenced by CRecycleBin::CompareIDs(), CRecyclerExtractIcon_CreateInstance(), CRecycleBin::GetDetailsOf(), CRecycleBin::GetDisplayNameOf(), and CRecycleBinItemContextMenu::InvokeCommand().

◆ CBSearchRecycleBin()

BOOL WINAPI CBSearchRecycleBin ( IN PVOID  Context,
IN HDELFILE  hDeletedFile 
)

Definition at line 158 of file CRecycleBin.cpp.

159{
161
162 PDELETED_FILE_DETAILS_W pFileDetails;
164 BOOL ret;
165
166 if (!GetDeletedFileDetailsW(hDeletedFile,
167 0,
168 NULL,
169 &dwSize) &&
171 {
172 ERR("GetDeletedFileDetailsW failed\n");
173 return FALSE;
174 }
175
176 pFileDetails = (DELETED_FILE_DETAILS_W *)SHAlloc(dwSize);
177 if (!pFileDetails)
178 {
179 ERR("No memory\n");
180 return FALSE;
181 }
182
183 if (!GetDeletedFileDetailsW(hDeletedFile,
184 dwSize,
185 pFileDetails,
186 NULL))
187 {
188 ERR("GetDeletedFileDetailsW failed\n");
189 SHFree(pFileDetails);
190 return FALSE;
191 }
192
193 ret = memcmp(pFileDetails, pContext->pFileDetails, dwSize);
194 if (!ret)
195 {
196 pContext->hDeletedFile = hDeletedFile;
197 pContext->bFound = TRUE;
198 }
199 else
200 CloseRecycleBinHandle(hDeletedFile);
201
202 SHFree(pFileDetails);
203 return ret;
204}
struct _SEARCH_CONTEXT * PSEARCH_CONTEXT
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERR(fmt,...)
Definition: debug.h:113
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI CloseRecycleBinHandle(IN HDELFILE hDeletedFile)
Definition: recyclebin.c:12
BOOL WINAPI GetDeletedFileDetailsW(IN HDELFILE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
Definition: recyclebin.c:327
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
PIDLRecycleStruct * pFileDetails
Definition: CRecycleBin.cpp:71
HDELFILE hDeletedFile
Definition: CRecycleBin.cpp:72
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by CRecyclerExtractIcon_CreateInstance(), CRecycleBin::GetDetailsOf(), and CRecycleBinItemContextMenu::InvokeCommand().

◆ CRecyclerExtractIcon_CreateInstance()

HRESULT CRecyclerExtractIcon_CreateInstance ( LPCITEMIDLIST  pidl,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 76 of file CRecycleBin.cpp.

78{
79 PIDLRecycleStruct *pFileDetails = _ILGetRecycleStruct(pidl);
80 if (pFileDetails == NULL)
81 goto fallback;
82
83 // Try to obtain the file
85 Context.pFileDetails = pFileDetails;
86 Context.bFound = FALSE;
87
89 if (Context.bFound)
90 {
91 // This should be executed any time, if not, there are some errors in the implementation
92 IRecycleBinFile* pRecycleFile = (IRecycleBinFile*)Context.hDeletedFile;
93
94 // Query the interface from the private interface
95 HRESULT hr = pRecycleFile->QueryInterface(riid, ppvOut);
96
97 // Close the file handle as we don't need it anymore
98 CloseRecycleBinHandle(Context.hDeletedFile);
99
100 return hr;
101 }
102
103fallback:
104 // In case the search fails we use a default icon
105 ERR("Recycler could not retrieve the icon, this shouldn't happen\n");
106
107 CComPtr<IDefaultExtractIconInit> initIcon;
110 return hr;
111
112 initIcon->SetNormalIcon(swShell32Name, 0);
113
114 return initIcon->QueryInterface(riid, ppvOut);
115}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
static PIDLRecycleStruct * _ILGetRecycleStruct(LPCITEMIDLIST pidl)
BOOL WINAPI CBSearchRecycleBin(IN PVOID Context, IN HDELFILE hDeletedFile)
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
BOOL WINAPI EnumerateRecycleBinW(IN LPCWSTR pszRoot OPTIONAL, IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL)
Definition: recyclebin.c:205
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)

Referenced by CRecycleBin::GetUIObjectOf().

◆ FormatDateTime()

static HRESULT FormatDateTime ( LPWSTR  buffer,
int  size,
FILETIME ft 
)
static

Definition at line 722 of file CRecycleBin.cpp.

723{
724 FILETIME lft;
726 int ret;
727
728 FileTimeToLocalFileTime(ft, &lft);
730
732 if (ret > 0 && ret < size)
733 {
734 /* Append space + time without seconds */
735 buffer[ret-1] = ' ';
737 }
738
739 return (ret != 0 ? E_FAIL : S_OK);
740}
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
GLuint buffer
Definition: glext.h:5915
#define S_OK
Definition: intsafe.h:52
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
__u16 time
Definition: mkdosfs.c:8
#define LOCALE_USER_DEFAULT
#define TIME_NOSECONDS
Definition: winnls.h:278
#define DATE_SHORTDATE
Definition: winnls.h:196

◆ SHEmptyRecycleBinA()

HRESULT WINAPI SHEmptyRecycleBinA ( HWND  hwnd,
LPCSTR  pszRootPath,
DWORD  dwFlags 
)

Definition at line 1092 of file CRecycleBin.cpp.

1093{
1094 LPWSTR szRootPathW = NULL;
1095 int len;
1096 HRESULT hr;
1097
1098 TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1099
1100 if (pszRootPath)
1101 {
1102 len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1103 if (len == 0)
1105 szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1106 if (!szRootPathW)
1107 return E_OUTOFMEMORY;
1108 if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1109 {
1110 HeapFree(GetProcessHeap(), 0, szRootPathW);
1112 }
1113 }
1114
1115 hr = SHEmptyRecycleBinW(hwnd, szRootPathW, dwFlags);
1116 HeapFree(GetProcessHeap(), 0, szRootPathW);
1117
1118 return hr;
1119}
HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ SHEmptyRecycleBinW()

HRESULT WINAPI SHEmptyRecycleBinW ( HWND  hwnd,
LPCWSTR  pszRootPath,
DWORD  dwFlags 
)

Definition at line 1121 of file CRecycleBin.cpp.

1122{
1123 WCHAR szBuffer[MAX_PATH];
1124 DWORD count;
1125 LONG ret;
1126 IShellFolder *pDesktop, *pRecycleBin;
1127 PIDLIST_ABSOLUTE pidlRecycleBin;
1128 PITEMID_CHILD pidl;
1129 HRESULT hr = S_OK;
1130 LPENUMIDLIST penumFiles;
1131 STRRET StrRet;
1132
1133 TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1134
1136 {
1137 hr = SHGetDesktopFolder(&pDesktop);
1138 if (FAILED(hr))
1139 return hr;
1140 hr = SHGetFolderLocation(NULL, CSIDL_BITBUCKET, NULL, 0, &pidlRecycleBin);
1141 if (FAILED(hr))
1142 {
1143 pDesktop->Release();
1144 return hr;
1145 }
1146 hr = pDesktop->BindToObject(pidlRecycleBin, NULL, IID_PPV_ARG(IShellFolder, &pRecycleBin));
1147 CoTaskMemFree(pidlRecycleBin);
1148 pDesktop->Release();
1149 if (FAILED(hr))
1150 return hr;
1151 hr = pRecycleBin->EnumObjects(hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penumFiles);
1152 if (FAILED(hr))
1153 {
1154 pRecycleBin->Release();
1155 return hr;
1156 }
1157
1158 count = 0;
1159 if (hr != S_FALSE)
1160 {
1161 while (penumFiles->Next(1, &pidl, NULL) == S_OK)
1162 {
1163 count++;
1164 pRecycleBin->GetDisplayNameOf(pidl, SHGDN_NORMAL, &StrRet);
1165 StrRetToBuf(&StrRet, pidl, szBuffer, _countof(szBuffer));
1166 CoTaskMemFree(pidl);
1167 }
1168 penumFiles->Release();
1169 }
1170 pRecycleBin->Release();
1171
1172 switch (count)
1173 {
1174 case 0:
1175 /* no files, don't need confirmation */
1176 break;
1177
1178 case 1:
1179 /* we have only one item inside the bin, so show a message box with its name */
1182 {
1183 return S_OK;
1184 }
1185 break;
1186
1187 default:
1188 /* we have more than one item, so show a message box with the count of the items */
1189 StringCbPrintfW(szBuffer, sizeof(szBuffer), L"%u", count);
1192 {
1193 return S_OK;
1194 }
1195 break;
1196 }
1197 }
1198
1200 {
1201 ret = EmptyRecycleBinW(pszRootPath);
1202 }
1203 else
1204 {
1205 /* FIXME
1206 * show a progress dialog
1207 */
1208 ret = EmptyRecycleBinW(pszRootPath);
1209 }
1210
1211 if (!ret)
1213
1214 if (!(dwFlags & SHERB_NOSOUND))
1215 {
1217 }
1218 return S_OK;
1219}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
static void TRASH_PlayEmptyRecycleBinSound()
#define shell32_hInstance
#define MAX_PATH
Definition: compat.h:34
#define ShellMessageBoxW
Definition: precomp.h:59
BOOL WINAPI EmptyRecycleBinW(IN LPCWSTR pszRoot OPTIONAL)
Definition: recyclebin.c:145
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3124
GLuint GLuint GLsizei count
Definition: gl.h:1545
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT EnumObjects([in] HWND hwndOwner, [in] SHCONTF grfFlags, [out] IEnumIDList **ppenumIDList)
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
ULONG Release()
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define SHERB_NOSOUND
Definition: shellapi.h:398
#define SHERB_NOPROGRESSUI
Definition: shellapi.h:397
#define SHERB_NOCONFIRMATION
Definition: shellapi.h:396
#define StrRet
Definition: shellclasses.h:871
#define CSIDL_BITBUCKET
Definition: shlobj.h:2169
#define StrRetToBuf
Definition: shlwapi.h:1769
#define IDS_DELETEITEM_TEXT
Definition: shresdef.h:126
#define IDS_EMPTY_BITBUCKET
Definition: shresdef.h:185
#define IDS_DELETEMULTIPLE_TEXT
Definition: shresdef.h:127
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define S_FALSE
Definition: winerror.h:2357
#define MB_YESNO
Definition: winuser.h:817
#define IDNO
Definition: winuser.h:836
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_DEFBUTTON2
Definition: winuser.h:799
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by CRecycleBin::InvokeCommand(), and SHEmptyRecycleBinA().

◆ SHQueryRecycleBinA()

HRESULT WINAPI SHQueryRecycleBinA ( LPCSTR  pszRootPath,
LPSHQUERYRBINFO  pSHQueryRBInfo 
)

Definition at line 1221 of file CRecycleBin.cpp.

1222{
1223 LPWSTR szRootPathW = NULL;
1224 int len;
1225 HRESULT hr;
1226
1227 TRACE("%s, %p\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1228
1229 if (pszRootPath)
1230 {
1231 len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1232 if (len == 0)
1234 szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1235 if (!szRootPathW)
1236 return E_OUTOFMEMORY;
1237 if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1238 {
1239 HeapFree(GetProcessHeap(), 0, szRootPathW);
1241 }
1242 }
1243
1244 hr = SHQueryRecycleBinW(szRootPathW, pSHQueryRBInfo);
1245 HeapFree(GetProcessHeap(), 0, szRootPathW);
1246
1247 return hr;
1248}
HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)

◆ SHQueryRecycleBinW()

HRESULT WINAPI SHQueryRecycleBinW ( LPCWSTR  pszRootPath,
LPSHQUERYRBINFO  pSHQueryRBInfo 
)

Definition at line 1250 of file CRecycleBin.cpp.

1251{
1252 TRACE("%s, %p\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1253
1254 if (!pszRootPath || (pszRootPath[0] == 0) ||
1255 !pSHQueryRBInfo || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO)))
1256 {
1257 return E_INVALIDARG;
1258 }
1259
1260 pSHQueryRBInfo->i64Size = 0;
1261 pSHQueryRBInfo->i64NumItems = 0;
1262
1263 CComPtr<IRecycleBin> spRecycleBin;
1264 HRESULT hr;
1265 if (FAILED_UNEXPECTEDLY((hr = GetDefaultRecycleBin(pszRootPath, &spRecycleBin))))
1266 return hr;
1267
1268 CComPtr<IRecycleBinEnumList> spEnumList;
1269 hr = spRecycleBin->EnumObjects(&spEnumList);
1270 if (!SUCCEEDED(hr))
1271 return hr;
1272
1273 while (TRUE)
1274 {
1275 CComPtr<IRecycleBinFile> spFile;
1276 hr = spEnumList->Next(1, &spFile, NULL);
1277 if (hr == S_FALSE)
1278 return S_OK;
1279
1281 return hr;
1282
1283 ULARGE_INTEGER Size = {};
1284 if (FAILED_UNEXPECTEDLY((hr = spFile->GetFileSize(&Size))))
1285 return hr;
1286
1287 pSHQueryRBInfo->i64Size += Size.QuadPart;
1288 pSHQueryRBInfo->i64NumItems++;
1289 }
1290
1291 return S_OK;
1292}
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:399
#define SUCCEEDED(hr)
Definition: intsafe.h:50
__int64 i64Size
Definition: shellapi.h:380
__int64 i64NumItems
Definition: shellapi.h:381
DWORD cbSize
Definition: shellapi.h:379
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by SHQueryRecycleBinA().

◆ SHUpdateRecycleBinIcon()

EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon ( void  )

Definition at line 1077 of file CRecycleBin.cpp.

1078{
1079 FIXME("stub\n");
1080
1081 // HACK! This dwItem2 should be the icon index in the system image list that has changed.
1082 // FIXME: Call SHMapPIDLToSystemImageListIndex
1083 DWORD dwItem2 = -1;
1084
1086 return S_OK;
1087}
#define FIXME(fmt,...)
Definition: debug.h:114
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define SHCNE_UPDATEIMAGE
Definition: shlobj.h:1891
#define SHCNF_DWORD
Definition: shlobj.h:1910

Referenced by SHFileOperationW().

◆ TRASH_CanTrashFile()

BOOL TRASH_CanTrashFile ( LPCWSTR  wszPath)

Tests whether a file can be trashed

Parameters
wszPathPath to the file to be trash
Returns
TRUE if the file can be trashed, FALSE otherwise

Definition at line 932 of file CRecycleBin.cpp.

933{
934 LONG ret;
935 DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength;
936 DWORD FileSystemFlags, dwSize, dwDisposition;
937 HKEY hKey;
938 WCHAR szBuffer[10];
939 WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\BitBucket\\Volume\\";
940
941 if (wszPath[1] != L':')
942 {
943 /* path is UNC */
944 return FALSE;
945 }
946
947 // Copy and retrieve the root path from get given string
948 WCHAR wszRootPathName[MAX_PATH];
949 StringCbCopyW(wszRootPathName, sizeof(wszRootPathName), wszPath);
950 PathStripToRootW(wszRootPathName);
951
952 // Test to see if the drive is fixed (non removable)
953 if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
954 {
955 /* no bitbucket on removable media */
956 return FALSE;
957 }
958
959 if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0))
960 {
961 ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", GetLastError(), debugstr_w(wszRootPathName));
962 return FALSE;
963 }
964
965 swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber));
966 wcscat(szKey, szBuffer);
967
968 if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS)
969 {
970 ERR("RegCreateKeyExW failed\n");
971 return FALSE;
972 }
973
974 if (dwDisposition & REG_CREATED_NEW_KEY)
975 {
976 /* per default move to bitbucket */
977 dwNukeOnDelete = 0;
978 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
979 /* per default unlimited size */
980 dwSize = -1;
981 RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
983 return TRUE;
984 }
985 else
986 {
987 dwSize = sizeof(dwNukeOnDelete);
988 ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize);
989 if (ret != ERROR_SUCCESS)
990 {
992 {
993 /* restore key and enable bitbucket */
994 dwNukeOnDelete = 0;
995 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
996 }
998 return TRUE;
999 }
1000 else if (dwNukeOnDelete)
1001 {
1002 /* do not delete to bitbucket */
1004 return FALSE;
1005 }
1006 /* FIXME
1007 * check if bitbucket is full
1008 */
1010 return TRUE;
1011 }
1012}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
#define swprintf
Definition: precomp.h:40
FxAutoRegKey hKey
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define KEY_WRITE
Definition: nt_native.h:1031
#define LOWORD(l)
Definition: pedump.c:82
#define REG_DWORD
Definition: sdbapi.c:596
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
#define DRIVE_FIXED
Definition: winbase.h:252
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by delete_files().

◆ TRASH_PlayEmptyRecycleBinSound()

static void TRASH_PlayEmptyRecycleBinSound ( )
static

Definition at line 1021 of file CRecycleBin.cpp.

1022{
1023 CRegKey regKey;
1024 CHeapPtr<WCHAR> pszValue;
1025 CHeapPtr<WCHAR> pszSndPath;
1026 DWORD dwType, dwSize;
1027 LONG lError;
1028
1029 lError = regKey.Open(HKEY_CURRENT_USER,
1030 L"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
1031 KEY_READ);
1032 if (lError != ERROR_SUCCESS)
1033 return;
1034
1035 lError = regKey.QueryValue(NULL, &dwType, NULL, &dwSize);
1036 if (lError != ERROR_SUCCESS)
1037 return;
1038
1039 if (!pszValue.AllocateBytes(dwSize))
1040 return;
1041
1042 lError = regKey.QueryValue(NULL, &dwType, pszValue, &dwSize);
1043 if (lError != ERROR_SUCCESS)
1044 return;
1045
1046 if (dwType == REG_EXPAND_SZ)
1047 {
1048 dwSize = ExpandEnvironmentStringsW(pszValue, NULL, 0);
1049 if (dwSize == 0)
1050 return;
1051
1052 if (!pszSndPath.Allocate(dwSize))
1053 return;
1054
1055 if (ExpandEnvironmentStringsW(pszValue, pszSndPath, dwSize) == 0)
1056 return;
1057 }
1058 else if (dwType == REG_SZ)
1059 {
1060 /* The type is REG_SZ, no need to expand */
1061 pszSndPath.Attach(pszValue.Detach());
1062 }
1063 else
1064 {
1065 /* Invalid type */
1066 return;
1067 }
1068
1070}
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
T * Detach()
Definition: atlalloc.h:168
bool Allocate(_In_ size_t nElements=1)
Definition: atlalloc.h:143
void Attach(T *lp)
Definition: atlalloc.h:162
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define REG_SZ
Definition: layer.c:22
#define SND_FILENAME
Definition: mmsystem.h:162
#define SND_ASYNC
Definition: mmsystem.h:154
#define SND_NODEFAULT
Definition: mmsystem.h:155
#define KEY_READ
Definition: nt_native.h:1023
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:653

Referenced by SHEmptyRecycleBinW().

◆ TRASH_TrashFile()

BOOL TRASH_TrashFile ( LPCWSTR  wszPath)

Definition at line 1015 of file CRecycleBin.cpp.

1016{
1017 TRACE("(%s)\n", debugstr_w(wszPath));
1018 return DeleteFileToRecycleBin(wszPath);
1019}
#define DeleteFileToRecycleBin
Definition: recyclebin.h:85

Referenced by delete_files().

◆ UnpackDetailsFromPidl()

PDELETED_FILE_DETAILS_W UnpackDetailsFromPidl ( LPCITEMIDLIST  pidl)

Definition at line 511 of file CRecycleBin.cpp.

512{
513 return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID;
514}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( CRecycleBin  )

Variable Documentation

◆ RecycleBinColumns

const columninfo RecycleBinColumns[]
static
Initial value:
=
{
}
#define IDS_SHV_COLUMN_TYPE
Definition: resource.h:75
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:74
#define PID_STG_STORAGETYPE
Definition: ntquery.h:50
#define PID_STG_WRITETIME
Definition: ntquery.h:60
#define PID_STG_SIZE
Definition: ntquery.h:58
#define PID_STG_NAME
Definition: ntquery.h:56
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCFMT_RIGHT
Definition: commctrl.h:2599
#define PID_DISPLACED_FROM
Definition: shlguid.h:181
#define PID_DISPLACED_DATE
Definition: shlguid.h:182
#define IDS_SHV_COLUMN_DELFROM
Definition: shresdef.h:60
#define IDS_SHV_COLUMN_SIZE
Definition: shresdef.h:52
#define IDS_SHV_COLUMN_MODIFIED
Definition: shresdef.h:54
#define IDS_SHV_COLUMN_DELDATE
Definition: shresdef.h:61
@ SHCOLSTATE_TYPE_INT
Definition: shtypes.idl:122
@ SHCOLSTATE_TYPE_DATE
Definition: shtypes.idl:123
@ SHCOLSTATE_TYPE_STR
Definition: shtypes.idl:121
@ SHCOLSTATE_ONBYDEFAULT
Definition: shtypes.idl:125

Definition at line 40 of file CRecycleBin.cpp.

Referenced by CRecycleBin::GetDefaultColumnState(), CRecycleBin::GetDetailsOf(), and CRecycleBin::MapColumnToSCID().