ReactOS 0.4.17-dev-1190-g4c812f4
CRecycleBin.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CRecycleBin
 

Functions

BOOL TRASH_CanTrashFile (LPCWSTR wszPath)
 
BOOL TRASH_TrashFile (LPCWSTR wszPath)
 
HRESULT CRecyclerDropTarget_CreateInstance (REFIID riid, LPVOID *ppvOut)
 

Function Documentation

◆ CRecyclerDropTarget_CreateInstance()

HRESULT CRecyclerDropTarget_CreateInstance ( REFIID  riid,
LPVOID *  ppvOut 
)

Definition at line 183 of file CRecyclerDropTarget.cpp.

184{
185 return ShellObjectCreator<CRecyclerDropTarget>(riid, ppvOut);
186}
REFIID riid
Definition: atlbase.h:39

Referenced by CRecycleBin::CreateViewObject(), and CDefaultContextMenu::DoDelete().

◆ 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 1149 of file CRecycleBin.cpp.

1150{
1151 LONG ret;
1152 DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength;
1153 DWORD FileSystemFlags, dwSize, dwDisposition;
1154 HKEY hKey;
1155 WCHAR szBuffer[10];
1156 WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\BitBucket\\Volume\\";
1157
1158 if (wszPath[1] != L':')
1159 {
1160 /* path is UNC */
1161 return FALSE;
1162 }
1163
1164 // Copy and retrieve the root path from get given string
1165 WCHAR wszRootPathName[MAX_PATH];
1166 StringCbCopyW(wszRootPathName, sizeof(wszRootPathName), wszPath);
1167 PathStripToRootW(wszRootPathName);
1168
1169 // Test to see if the drive is fixed (non removable)
1170 if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
1171 {
1172 /* no bitbucket on removable media */
1173 return FALSE;
1174 }
1175
1176 if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0))
1177 {
1178 ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", GetLastError(), debugstr_w(wszRootPathName));
1179 return FALSE;
1180 }
1181
1182 _swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber));
1183 wcscat(szKey, szBuffer);
1184
1185 if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS)
1186 {
1187 ERR("RegCreateKeyExW failed\n");
1188 return FALSE;
1189 }
1190
1191 if (dwDisposition & REG_CREATED_NEW_KEY)
1192 {
1193 /* per default move to bitbucket */
1194 dwNukeOnDelete = 0;
1195 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
1196 /* per default unlimited size */
1197 dwSize = -1;
1198 RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
1199 }
1200 else
1201 {
1202 dwSize = sizeof(dwNukeOnDelete);
1203 ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize);
1204 if (ret != ERROR_SUCCESS)
1205 {
1206 dwNukeOnDelete = 0;
1208 {
1209 /* restore key and enable bitbucket */
1210 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
1211 }
1212 }
1213 }
1214 BOOL bCanTrash = !dwNukeOnDelete;
1215 // FIXME: Check if bitbucket is full (CORE-13743)
1217 return bCanTrash;
1218}
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
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
#define MAX_PATH
Definition: compat.h:34
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(WCHAR *path)
Definition: path.c:1171
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
#define KEY_READ
Definition: nt_native.h:1026
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1087
#define KEY_WRITE
Definition: nt_native.h:1034
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:615
wcscat
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
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DRIVE_FIXED
Definition: winbase.h:277
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by delete_files().

◆ TRASH_TrashFile()

BOOL TRASH_TrashFile ( LPCWSTR  wszPath)

Definition at line 1221 of file CRecycleBin.cpp.

1222{
1223 TRACE("(%s)\n", debugstr_w(wszPath));
1224 return DeleteFileToRecycleBin(wszPath);
1225}
#define DeleteFileToRecycleBin
Definition: recyclebin.h:101
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by delete_files().