ReactOS  0.4.15-dev-4853-g3a72a52
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 HANDLE 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)
 
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 }
WCHAR FileName[ANY_SIZE]
Definition: recyclebin.h:40
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
GLfloat GLfloat p
Definition: glext.h:8902
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304

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 }
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2187
static PROTOCOLDATA * pdata
Definition: protocol.c:158
#define NULL
Definition: types.h:112

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

◆ CBSearchRecycleBin()

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

Definition at line 158 of file CRecycleBin.cpp.

159 {
161 
162  PDELETED_FILE_DETAILS_W pFileDetails;
163  DWORD dwSize;
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 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI GetDeletedFileDetailsW(IN HANDLE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
Definition: recyclebin.c:327
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CloseRecycleBinHandle(IN HANDLE hDeletedFile)
Definition: recyclebin.c:12
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
struct _SEARCH_CONTEXT * PSEARCH_CONTEXT
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
PIDLRecycleStruct * pFileDetails
Definition: CRecycleBin.cpp:71

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 
103 fallback:
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;
109  if (FAILED_UNEXPECTEDLY(hr))
110  return hr;
111 
112  initIcon->SetNormalIcon(swShell32Name, 0);
113 
114  return initIcon->QueryInterface(riid, ppvOut);
115 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
#define IID_PPV_ARG(Itype, ppType)
#define FALSE
Definition: types.h:117
BOOL WINAPI CloseRecycleBinHandle(IN HANDLE hDeletedFile)
Definition: recyclebin.c:12
LONG HRESULT
Definition: typedefs.h:79
BOOL WINAPI CBSearchRecycleBin(IN PVOID Context, IN HANDLE hDeletedFile)
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
static PIDLRecycleStruct * _ILGetRecycleStruct(LPCITEMIDLIST pidl)
BOOL WINAPI EnumerateRecycleBinW(IN LPCWSTR pszRoot OPTIONAL, IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL)
Definition: recyclebin.c:205
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034

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);
729  FileTimeToSystemTime(&lft, &time);
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 LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:196
GLuint buffer
Definition: glext.h:5915
__u16 time
Definition: mkdosfs.c:366
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
GLsizeiptr size
Definition: glext.h:5919
int ret
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
#define TIME_NOSECONDS
Definition: winnls.h:278
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079

Referenced by CRecycleBin::GetDetailsOf().

◆ SHEmptyRecycleBinA()

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

Definition at line 1036 of file CRecycleBin.cpp.

1037 {
1038  LPWSTR szRootPathW = NULL;
1039  int len;
1040  HRESULT hr;
1041 
1042  TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1043 
1044  if (pszRootPath)
1045  {
1046  len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1047  if (len == 0)
1048  return HRESULT_FROM_WIN32(GetLastError());
1049  szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1050  if (!szRootPathW)
1051  return E_OUTOFMEMORY;
1052  if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1053  {
1054  HeapFree(GetProcessHeap(), 0, szRootPathW);
1055  return HRESULT_FROM_WIN32(GetLastError());
1056  }
1057  }
1058 
1059  hr = SHEmptyRecycleBinW(hwnd, szRootPathW, dwFlags);
1060  HeapFree(GetProcessHeap(), 0, szRootPathW);
1061 
1062  return hr;
1063 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:79
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ SHEmptyRecycleBinW()

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

Definition at line 1065 of file CRecycleBin.cpp.

1066 {
1067  WCHAR szPath[MAX_PATH] = {0}, szBuffer[MAX_PATH];
1068  DWORD dwSize, dwType, count;
1069  LONG ret;
1070  IShellFolder *pDesktop, *pRecycleBin;
1071  PIDLIST_ABSOLUTE pidlRecycleBin;
1072  PITEMID_CHILD pidl;
1073  HRESULT hr = S_OK;
1074  LPENUMIDLIST penumFiles;
1075  STRRET StrRet;
1076 
1077  TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1078 
1079  if (!(dwFlags & SHERB_NOCONFIRMATION))
1080  {
1081  hr = SHGetDesktopFolder(&pDesktop);
1082  if (FAILED(hr))
1083  return hr;
1084  hr = SHGetFolderLocation(NULL, CSIDL_BITBUCKET, NULL, 0, &pidlRecycleBin);
1085  if (FAILED(hr))
1086  {
1087  pDesktop->Release();
1088  return hr;
1089  }
1090  hr = pDesktop->BindToObject(pidlRecycleBin, NULL, IID_PPV_ARG(IShellFolder, &pRecycleBin));
1091  CoTaskMemFree(pidlRecycleBin);
1092  pDesktop->Release();
1093  if (FAILED(hr))
1094  return hr;
1095  hr = pRecycleBin->EnumObjects(hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penumFiles);
1096  if (FAILED(hr))
1097  {
1098  pRecycleBin->Release();
1099  return hr;
1100  }
1101 
1102  count = 0;
1103  if (hr != S_FALSE)
1104  {
1105  while (penumFiles->Next(1, &pidl, NULL) == S_OK)
1106  {
1107  count++;
1108  pRecycleBin->GetDisplayNameOf(pidl, SHGDN_NORMAL, &StrRet);
1109  StrRetToBuf(&StrRet, pidl, szBuffer, _countof(szBuffer));
1110  CoTaskMemFree(pidl);
1111  }
1112  penumFiles->Release();
1113  }
1114  pRecycleBin->Release();
1115 
1116  switch (count)
1117  {
1118  case 0:
1119  /* no files, don't need confirmation */
1120  break;
1121 
1122  case 1:
1123  /* we have only one item inside the bin, so show a message box with its name */
1125  MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2, szBuffer) == IDNO)
1126  {
1127  return S_OK;
1128  }
1129  break;
1130 
1131  default:
1132  /* we have more than one item, so show a message box with the count of the items */
1133  StringCbPrintfW(szBuffer, sizeof(szBuffer), L"%u", count);
1135  MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2, szBuffer) == IDNO)
1136  {
1137  return S_OK;
1138  }
1139  break;
1140  }
1141  }
1142 
1144  {
1145  ret = EmptyRecycleBinW(pszRootPath);
1146  }
1147  else
1148  {
1149  /* FIXME
1150  * show a progress dialog
1151  */
1152  ret = EmptyRecycleBinW(pszRootPath);
1153  }
1154 
1155  if (!ret)
1156  return HRESULT_FROM_WIN32(GetLastError());
1157 
1158  if (!(dwFlags & SHERB_NOSOUND))
1159  {
1160  dwSize = sizeof(szPath);
1162  L"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
1163  NULL,
1164  RRF_RT_REG_SZ,
1165  &dwType,
1166  (PVOID)szPath,
1167  &dwSize);
1168  if (ret != ERROR_SUCCESS)
1169  return S_OK;
1170 
1171  if (dwType != REG_EXPAND_SZ) /* type dismatch */
1172  return S_OK;
1173 
1174  szPath[_countof(szPath)-1] = L'\0';
1176  }
1177  return S_OK;
1178 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define RRF_RT_REG_SZ
Definition: driver.c:575
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define CSIDL_BITBUCKET
Definition: shlobj.h:2022
#define IID_PPV_ARG(Itype, ppType)
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define L(x)
Definition: ntvdm.h:50
#define MB_YESNO
Definition: winuser.h:811
long LONG
Definition: pedump.c:60
#define StrRetToBuf
Definition: shlwapi.h:1769
#define debugstr_w
Definition: kernel32.h:32
HRESULT EnumObjects([in] HWND hwndOwner, [in] SHCONTF grfFlags, [out] IEnumIDList **ppenumIDList)
#define StrRet
Definition: shellclasses.h:871
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
#define IDS_DELETEITEM_TEXT
Definition: shresdef.h:124
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SHERB_NOSOUND
Definition: shellapi.h:396
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI EmptyRecycleBinW(IN LPCWSTR pszRoot OPTIONAL)
Definition: recyclebin.c:145
#define IDS_DELETEMULTIPLE_TEXT
Definition: shresdef.h:125
#define IDS_EMPTY_BITBUCKET
Definition: shresdef.h:182
#define SND_FILENAME
Definition: mmsystem.h:162
#define S_OK
Definition: intsafe.h:52
#define shell32_hInstance
LPCWSTR szPath
Definition: env.c:37
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define SHERB_NOCONFIRMATION
Definition: shellapi.h:394
#define ShellMessageBoxW
Definition: precomp.h:63
#define NULL
Definition: types.h:112
#define MB_DEFBUTTON2
Definition: winuser.h:793
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2883
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDNO
Definition: winuser.h:830
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define SHERB_NOPROGRESSUI
Definition: shellapi.h:395
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:531

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

◆ SHQueryRecycleBinA()

HRESULT WINAPI SHQueryRecycleBinA ( LPCSTR  pszRootPath,
LPSHQUERYRBINFO  pSHQueryRBInfo 
)

Definition at line 1180 of file CRecycleBin.cpp.

1181 {
1182  LPWSTR szRootPathW = NULL;
1183  int len;
1184  HRESULT hr;
1185 
1186  TRACE("%s, %p\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1187 
1188  if (pszRootPath)
1189  {
1190  len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1191  if (len == 0)
1192  return HRESULT_FROM_WIN32(GetLastError());
1193  szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1194  if (!szRootPathW)
1195  return E_OUTOFMEMORY;
1196  if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1197  {
1198  HeapFree(GetProcessHeap(), 0, szRootPathW);
1199  return HRESULT_FROM_WIN32(GetLastError());
1200  }
1201  }
1202 
1203  hr = SHQueryRecycleBinW(szRootPathW, pSHQueryRBInfo);
1204  HeapFree(GetProcessHeap(), 0, szRootPathW);
1205 
1206  return hr;
1207 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:79
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ SHQueryRecycleBinW()

HRESULT WINAPI SHQueryRecycleBinW ( LPCWSTR  pszRootPath,
LPSHQUERYRBINFO  pSHQueryRBInfo 
)

Definition at line 1209 of file CRecycleBin.cpp.

1210 {
1211  FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1212 
1213  if (!(pszRootPath) || (pszRootPath[0] == 0) ||
1214  !(pSHQueryRBInfo) || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO)))
1215  {
1216  return E_INVALIDARG;
1217  }
1218 
1219  pSHQueryRBInfo->i64Size = 0;
1220  pSHQueryRBInfo->i64NumItems = 0;
1221 
1222  return S_OK;
1223 }
DWORD cbSize
Definition: shellapi.h:377
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_INVALIDARG
Definition: ddrawi.h:101
__int64 i64Size
Definition: shellapi.h:378
#define S_OK
Definition: intsafe.h:52
__int64 i64NumItems
Definition: shellapi.h:379

Referenced by SHQueryRecycleBinA().

◆ SHUpdateRecycleBinIcon()

EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon ( void  )

Definition at line 1026 of file CRecycleBin.cpp.

1027 {
1028  FIXME("stub\n");
1029 
1030  return S_OK;
1031 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_OK
Definition: intsafe.h:52

◆ 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));
982  RegCloseKey(hKey);
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  {
991  if (ret == ERROR_FILE_NOT_FOUND)
992  {
993  /* restore key and enable bitbucket */
994  dwNukeOnDelete = 0;
995  RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
996  }
997  RegCloseKey(hKey);
998  return TRUE;
999  }
1000  else if (dwNukeOnDelete)
1001  {
1002  /* do not delete to bitbucket */
1003  RegCloseKey(hKey);
1004  return FALSE;
1005  }
1006  /* FIXME
1007  * check if bitbucket is full
1008  */
1009  RegCloseKey(hKey);
1010  return TRUE;
1011  }
1012 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
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:1091
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
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:4899
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
int _cdecl swprintf(const WCHAR *,...)
#define DRIVE_FIXED
Definition: winbase.h:249
#define ERR(fmt,...)
Definition: debug.h:110
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
FxAutoRegKey hKey
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define REG_DWORD
Definition: sdbapi.c:596
#define LOWORD(l)
Definition: pedump.c:82
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by delete_files().

◆ 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 debugstr_w
Definition: kernel32.h:32
#define DeleteFileToRecycleBin
Definition: recyclebin.h:82
#define TRACE(s)
Definition: solgame.cpp:4

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 PID_STG_WRITETIME
Definition: ntquery.h:60
#define LVCFMT_RIGHT
Definition: commctrl.h:2599
#define IDS_SHV_COLUMN_DELFROM
Definition: shresdef.h:60
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define PID_STG_NAME
Definition: ntquery.h:56
#define IDS_SHV_COLUMN_TYPE
Definition: resource.h:75
#define IDS_SHV_COLUMN_SIZE
Definition: shresdef.h:52
#define IDS_SHV_COLUMN_DELDATE
Definition: shresdef.h:61
#define PID_DISPLACED_FROM
Definition: shlguid.h:181
#define PID_STG_SIZE
Definition: ntquery.h:58
#define PID_STG_STORAGETYPE
Definition: ntquery.h:50
#define IDS_SHV_COLUMN_MODIFIED
Definition: shresdef.h:54
#define PID_DISPLACED_DATE
Definition: shlguid.h:182
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:74

Definition at line 40 of file CRecycleBin.cpp.

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