ReactOS  0.4.15-dev-1018-g0695ecb
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
 
class  CRecycleBinEnum
 
class  CRecycleBinItemContextMenu
 
struct  SEARCH_CONTEXT
 

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_CONTEXTPSEARCH_CONTEXT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (CRecycleBin)
 
HRESULT CRecyclerExtractIcon_CreateInstance (LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
 
BOOL WINAPI CBSearchRecycleBin (IN PVOID Context, IN HANDLE hDeletedFile)
 
static PIDLRecycleStruct * _ILGetRecycleStruct (LPCITEMIDLIST pidl)
 
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

Function Documentation

◆ _ILCreateRecycleItem()

static LPITEMIDLIST _ILCreateRecycleItem ( PDELETED_FILE_DETAILS_W  pFileDetails)
static

Definition at line 219 of file CRecycleBin.cpp.

220 {
221  PIDLDATA tmp;
222  LPITEMIDLIST pidl;
223  PIDLRecycleStruct * p;
224  int size0 = (char*)&tmp.u.crecycle.szName - (char*)&tmp.u.crecycle;
225  int size = size0;
226 
227  tmp.type = 0x00;
228  size += (wcslen(pFileDetails->FileName) + 1) * sizeof(WCHAR);
229 
230  pidl = (LPITEMIDLIST)SHAlloc(size + 4);
231  if (!pidl)
232  return pidl;
233 
234  pidl->mkid.cb = size + 2;
235  memcpy(pidl->mkid.abID, &tmp, 2 + size0);
236 
237  p = &((PIDLDATA*)pidl->mkid.abID)->u.crecycle;
238  RtlCopyMemory(p, pFileDetails, sizeof(DELETED_FILE_DETAILS_W));
239  wcscpy(p->szName, pFileDetails->FileName);
240  *(WORD*)((char*)pidl + (size + 2)) = 0;
241  return pidl;
242 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
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
GLfloat GLfloat p
Definition: glext.h:8902
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CRecycleBinEnum::CBEnumRecycleBin().

◆ _ILGetRecycleStruct()

static PIDLRecycleStruct* _ILGetRecycleStruct ( LPCITEMIDLIST  pidl)
static

Definition at line 174 of file CRecycleBin.cpp.

175 {
177 
178  if (pdata && pdata->type == 0x00)
179  return (PIDLRecycleStruct*) & (pdata->u.crecycle);
180 
181  return NULL;
182 }
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2176
smooth NULL
Definition: ftsmooth.c:416
static PROTOCOLDATA * pdata
Definition: protocol.c:158

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

◆ CBSearchRecycleBin()

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

Definition at line 126 of file CRecycleBin.cpp.

127 {
129 
130  PDELETED_FILE_DETAILS_W pFileDetails;
131  DWORD dwSize;
132  BOOL ret;
133 
134  if (!GetDeletedFileDetailsW(hDeletedFile,
135  0,
136  NULL,
137  &dwSize) &&
139  {
140  ERR("GetDeletedFileDetailsW failed\n");
141  return FALSE;
142  }
143 
144  pFileDetails = (DELETED_FILE_DETAILS_W *)SHAlloc(dwSize);
145  if (!pFileDetails)
146  {
147  ERR("No memory\n");
148  return FALSE;
149  }
150 
151  if (!GetDeletedFileDetailsW(hDeletedFile,
152  dwSize,
153  pFileDetails,
154  NULL))
155  {
156  ERR("GetDeletedFileDetailsW failed\n");
157  SHFree(pFileDetails);
158  return FALSE;
159  }
160 
161  ret = memcmp(pFileDetails, pContext->pFileDetails, dwSize);
162  if (!ret)
163  {
164  pContext->hDeletedFile = hDeletedFile;
165  pContext->bFound = TRUE;
166  }
167  else
168  CloseRecycleBinHandle(hDeletedFile);
169 
170  SHFree(pFileDetails);
171  return ret;
172 }
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:1059
PIDLRecycleStruct * pFileDetails
BOOL WINAPI GetDeletedFileDetailsW(IN HANDLE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
Definition: recyclebin.c:301
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CloseRecycleBinHandle(IN HANDLE hDeletedFile)
Definition: recyclebin.c:12
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERR(fmt,...)
Definition: debug.h:110
struct SEARCH_CONTEXT * PSEARCH_CONTEXT
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CRecycleBinItemContextMenu::InvokeCommand().

◆ CRecyclerExtractIcon_CreateInstance()

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

Definition at line 65 of file CRecycleBin.cpp.

66 {
67  CComPtr<IDefaultExtractIconInit> initIcon;
70  return hr;
71 
72  /* FIXME: This is completely unimplemented */
73  initIcon->SetNormalIcon(swShell32Name, 0);
74 
75  return initIcon->QueryInterface(riid, ppvOut);
76 }
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)
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)

Referenced by CRecycleBin::GetUIObjectOf().

◆ FormatDateTime()

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

Definition at line 691 of file CRecycleBin.cpp.

692 {
693  FILETIME lft;
695  int ret;
696 
697  FileTimeToLocalFileTime(ft, &lft);
698  FileTimeToSystemTime(&lft, &time);
699 
701  if (ret > 0 && ret < size)
702  {
703  /* Append space + time without seconds */
704  buffer[ret-1] = ' ';
706  }
707 
708  return (ret != 0 ? E_FAIL : S_OK);
709 }
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
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
smooth NULL
Definition: ftsmooth.c:416
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:59
#define TIME_NOSECONDS
Definition: winnls.h:275
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 1000 of file CRecycleBin.cpp.

1001 {
1002  LPWSTR szRootPathW = NULL;
1003  int len;
1004  HRESULT hr;
1005 
1006  TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1007 
1008  if (pszRootPath)
1009  {
1010  len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1011  if (len == 0)
1012  return HRESULT_FROM_WIN32(GetLastError());
1013  szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1014  if (!szRootPathW)
1015  return E_OUTOFMEMORY;
1016  if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1017  {
1018  HeapFree(GetProcessHeap(), 0, szRootPathW);
1019  return HRESULT_FROM_WIN32(GetLastError());
1020  }
1021  }
1022 
1023  hr = SHEmptyRecycleBinW(hwnd, szRootPathW, dwFlags);
1024  HeapFree(GetProcessHeap(), 0, szRootPathW);
1025 
1026  return hr;
1027 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#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:1059
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
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 MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ SHEmptyRecycleBinW()

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

Definition at line 1029 of file CRecycleBin.cpp.

1030 {
1031  WCHAR szPath[MAX_PATH] = {0}, szBuffer[MAX_PATH];
1032  DWORD dwSize, dwType, count;
1033  LONG ret;
1034  IShellFolder *pDesktop, *pRecycleBin;
1035  PIDLIST_ABSOLUTE pidlRecycleBin;
1036  PITEMID_CHILD pidl;
1037  HRESULT hr = S_OK;
1038  LPENUMIDLIST penumFiles;
1039  STRRET StrRet;
1040 
1041  TRACE("%p, %s, 0x%08x\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1042 
1043  if (!(dwFlags & SHERB_NOCONFIRMATION))
1044  {
1045  hr = SHGetDesktopFolder(&pDesktop);
1046  if (FAILED(hr))
1047  return hr;
1048  hr = SHGetFolderLocation(NULL, CSIDL_BITBUCKET, NULL, 0, &pidlRecycleBin);
1049  if (FAILED(hr))
1050  {
1051  pDesktop->Release();
1052  return hr;
1053  }
1054  hr = pDesktop->BindToObject(pidlRecycleBin, NULL, IID_PPV_ARG(IShellFolder, &pRecycleBin));
1055  CoTaskMemFree(pidlRecycleBin);
1056  pDesktop->Release();
1057  if (FAILED(hr))
1058  return hr;
1059  hr = pRecycleBin->EnumObjects(hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penumFiles);
1060  if (FAILED(hr))
1061  {
1062  pRecycleBin->Release();
1063  return hr;
1064  }
1065 
1066  count = 0;
1067  if (hr != S_FALSE)
1068  {
1069  while (penumFiles->Next(1, &pidl, NULL) == S_OK)
1070  {
1071  count++;
1072  pRecycleBin->GetDisplayNameOf(pidl, SHGDN_NORMAL, &StrRet);
1073  StrRetToBuf(&StrRet, pidl, szBuffer, _countof(szBuffer));
1074  CoTaskMemFree(pidl);
1075  }
1076  penumFiles->Release();
1077  }
1078  pRecycleBin->Release();
1079 
1080  switch (count)
1081  {
1082  case 0:
1083  /* no files, don't need confirmation */
1084  break;
1085 
1086  case 1:
1087  /* we have only one item inside the bin, so show a message box with its name */
1089  MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2, szBuffer) == IDNO)
1090  {
1091  return S_OK;
1092  }
1093  break;
1094 
1095  default:
1096  /* we have more than one item, so show a message box with the count of the items */
1097  StringCbPrintfW(szBuffer, sizeof(szBuffer), L"%u", count);
1099  MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2, szBuffer) == IDNO)
1100  {
1101  return S_OK;
1102  }
1103  break;
1104  }
1105  }
1106 
1108  {
1109  ret = EmptyRecycleBinW(pszRootPath);
1110  }
1111  else
1112  {
1113  /* FIXME
1114  * show a progress dialog
1115  */
1116  ret = EmptyRecycleBinW(pszRootPath);
1117  }
1118 
1119  if (!ret)
1120  return HRESULT_FROM_WIN32(GetLastError());
1121 
1122  if (!(dwFlags & SHERB_NOSOUND))
1123  {
1124  dwSize = sizeof(szPath);
1126  L"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
1127  NULL,
1128  RRF_RT_REG_SZ,
1129  &dwType,
1130  (PVOID)szPath,
1131  &dwSize);
1132  if (ret != ERROR_SUCCESS)
1133  return S_OK;
1134 
1135  if (dwType != REG_EXPAND_SZ) /* type dismatch */
1136  return S_OK;
1137 
1138  szPath[_countof(szPath)-1] = L'\0';
1140  }
1141  return S_OK;
1142 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#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
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RRF_RT_REG_SZ
Definition: driver.c:575
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#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 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
smooth NULL
Definition: ftsmooth.c:416
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:116
#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
static const WCHAR L[]
Definition: oid.c:1250
_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:117
#define IDS_EMPTY_BITBUCKET
Definition: shresdef.h:174
#define SND_FILENAME
Definition: mmsystem.h:162
#define S_OK
Definition: intsafe.h:59
#define shell32_hInstance
LPCWSTR szPath
Definition: env.c:35
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define SHERB_NOCONFIRMATION
Definition: shellapi.h:394
#define ShellMessageBoxW
Definition: precomp.h:58
#define MB_DEFBUTTON2
Definition: winuser.h:793
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2741
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDNO
Definition: winuser.h:830
#define SHERB_NOPROGRESSUI
Definition: shellapi.h:395
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
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 1144 of file CRecycleBin.cpp.

1145 {
1146  LPWSTR szRootPathW = NULL;
1147  int len;
1148  HRESULT hr;
1149 
1150  TRACE("%s, %p\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1151 
1152  if (pszRootPath)
1153  {
1154  len = MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, NULL, 0);
1155  if (len == 0)
1156  return HRESULT_FROM_WIN32(GetLastError());
1157  szRootPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1158  if (!szRootPathW)
1159  return E_OUTOFMEMORY;
1160  if (MultiByteToWideChar(CP_ACP, 0, pszRootPath, -1, szRootPathW, len) == 0)
1161  {
1162  HeapFree(GetProcessHeap(), 0, szRootPathW);
1163  return HRESULT_FROM_WIN32(GetLastError());
1164  }
1165  }
1166 
1167  hr = SHQueryRecycleBinW(szRootPathW, pSHQueryRBInfo);
1168  HeapFree(GetProcessHeap(), 0, szRootPathW);
1169 
1170  return hr;
1171 }
#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:1059
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
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 MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ SHQueryRecycleBinW()

HRESULT WINAPI SHQueryRecycleBinW ( LPCWSTR  pszRootPath,
LPSHQUERYRBINFO  pSHQueryRBInfo 
)

Definition at line 1173 of file CRecycleBin.cpp.

1174 {
1175  FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1176 
1177  if (!(pszRootPath) || (pszRootPath[0] == 0) ||
1178  !(pSHQueryRBInfo) || (pSHQueryRBInfo->cbSize < sizeof(SHQUERYRBINFO)))
1179  {
1180  return E_INVALIDARG;
1181  }
1182 
1183  pSHQueryRBInfo->i64Size = 0;
1184  pSHQueryRBInfo->i64NumItems = 0;
1185 
1186  return S_OK;
1187 }
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:59
__int64 i64NumItems
Definition: shellapi.h:379

Referenced by SHQueryRecycleBinA().

◆ SHUpdateRecycleBinIcon()

EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon ( void  )

Definition at line 990 of file CRecycleBin.cpp.

991 {
992  FIXME("stub\n");
993 
994  return S_OK;
995 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_OK
Definition: intsafe.h:59

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

897 {
898  LONG ret;
899  DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength;
900  DWORD FileSystemFlags, dwSize, dwDisposition;
901  HKEY hKey;
902  WCHAR szBuffer[10];
903  WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\BitBucket\\Volume\\";
904 
905  if (wszPath[1] != L':')
906  {
907  /* path is UNC */
908  return FALSE;
909  }
910 
911  // Copy and retrieve the root path from get given string
912  WCHAR wszRootPathName[MAX_PATH];
913  StringCbCopyW(wszRootPathName, sizeof(wszRootPathName), wszPath);
914  PathStripToRootW(wszRootPathName);
915 
916  // Test to see if the drive is fixed (non removable)
917  if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
918  {
919  /* no bitbucket on removable media */
920  return FALSE;
921  }
922 
923  if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0))
924  {
925  ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", GetLastError(), debugstr_w(wszRootPathName));
926  return FALSE;
927  }
928 
929  swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber));
930  wcscat(szKey, szBuffer);
931 
932  if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS)
933  {
934  ERR("RegCreateKeyExW failed\n");
935  return FALSE;
936  }
937 
938  if (dwDisposition & REG_CREATED_NEW_KEY)
939  {
940  /* per default move to bitbucket */
941  dwNukeOnDelete = 0;
942  RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
943  /* per default unlimited size */
944  dwSize = -1;
945  RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
946  RegCloseKey(hKey);
947  return TRUE;
948  }
949  else
950  {
951  dwSize = sizeof(dwNukeOnDelete);
952  ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize);
953  if (ret != ERROR_SUCCESS)
954  {
955  if (ret == ERROR_FILE_NOT_FOUND)
956  {
957  /* restore key and enable bitbucket */
958  dwNukeOnDelete = 0;
959  RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
960  }
961  RegCloseKey(hKey);
962  return TRUE;
963  }
964  else if (dwNukeOnDelete)
965  {
966  /* do not delete to bitbucket */
967  RegCloseKey(hKey);
968  return FALSE;
969  }
970  /* FIXME
971  * check if bitbucket is full
972  */
973  RegCloseKey(hKey);
974  return TRUE;
975  }
976 }
#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:1059
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:728
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#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:4895
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#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
_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 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
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by delete_files().

◆ TRASH_TrashFile()

BOOL TRASH_TrashFile ( LPCWSTR  wszPath)

Definition at line 979 of file CRecycleBin.cpp.

980 {
981  TRACE("(%s)\n", debugstr_w(wszPath));
982  return DeleteFileToRecycleBin(wszPath);
983 }
#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 480 of file CRecycleBin.cpp.

481 {
482  return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID;
483 }

◆ 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:2595
#define IDS_SHV_COLUMN_DELFROM
Definition: shresdef.h:52
#define LVCFMT_LEFT
Definition: commctrl.h:2594
#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:44
#define IDS_SHV_COLUMN_DELDATE
Definition: shresdef.h:53
#define PID_DISPLACED_FROM
Definition: shlguid.h:178
#define PID_STG_SIZE
Definition: ntquery.h:58
#define PID_STG_STORAGETYPE
Definition: ntquery.h:50
#define IDS_SHV_COLUMN_MODIFIED
Definition: shresdef.h:46
#define PID_DISPLACED_DATE
Definition: shlguid.h:179
#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().