Revert 45697:
[reactos.git] / lib / recyclebin / recyclebin.h
1 #pragma once
2
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #include <windows.h>
8 #include <objbase.h>
9 #define ANY_SIZE 1
10
11 /* Structures used by the API Interface */
12
13 typedef struct _DELETED_FILE_DETAILS_A
14 {
15 FILETIME LastModification;
16 FILETIME DeletionTime;
17 ULARGE_INTEGER FileSize;
18 ULARGE_INTEGER PhysicalFileSize;
19 DWORD Attributes;
20 CHAR FileName[ANY_SIZE];
21 } DELETED_FILE_DETAILS_A, *PDELETED_FILE_DETAILS_A;
22 typedef struct _DELETED_FILE_DETAILS_W
23 {
24 FILETIME LastModification;
25 FILETIME DeletionTime;
26 ULARGE_INTEGER FileSize;
27 ULARGE_INTEGER PhysicalFileSize;
28 DWORD Attributes;
29 WCHAR FileName[ANY_SIZE];
30 } DELETED_FILE_DETAILS_W, *PDELETED_FILE_DETAILS_W;
31 #ifdef UNICODE
32 #define DELETED_FILE_DETAILS DELETED_FILE_DETAILS_W
33 #define PDELETED_FILE_DETAILS PDELETED_FILE_DETAILS_W
34 #else
35 #define DELETED_FILE_DETAILS DELETED_FILE_DETAILS_A
36 #define PDELETED_FILE_DETAILS PDELETED_FILE_DETAILS_A
37 #endif
38
39 /* API Interface */
40
41 /* Function called for each deleted file in the recycle bin
42 * Context: value given by the caller of the EnumerateRecycleBin function
43 * hDeletedFile: a handle to the deleted file
44 * Returning FALSE stops the enumeration.
45 * Remarks: the handle must be closed with the CloseRecycleBinHandle function
46 */
47 typedef BOOL (WINAPI *PENUMERATE_RECYCLEBIN_CALLBACK)(IN PVOID Context, IN HANDLE hDeletedFile);
48
49 /* Closes a file deleted handle.
50 * hDeletedFile: the handle to close
51 * Returns TRUE if operation succeeded, FALSE otherwise.
52 * Remark: The handle is obtained in the PENUMERATE_RECYCLEBIN_CALLBACK callback
53 */
54 BOOL WINAPI
55 CloseRecycleBinHandle(
56 IN HANDLE hDeletedFile);
57
58 /* Moves a file to the recycle bin.
59 * FileName: the name of the file to move the recycle bin
60 * Returns TRUE if operation succeeded, FALSE otherwise.
61 */
62 BOOL WINAPI
63 DeleteFileToRecycleBinA(
64 IN LPCSTR FileName);
65 BOOL WINAPI
66 DeleteFileToRecycleBinW(
67 IN LPCWSTR FileName);
68 #ifdef UNICODE
69 #define DeleteFileToRecycleBin DeleteFileToRecycleBinW
70 #else
71 #define DeleteFileToRecycleBin DeleteFileToRecycleBinA
72 #endif
73
74 /* Moves a file to the recycle bin.
75 * hDeletedFile: handle of the deleted file to delete
76 * Returns TRUE if operation succeeded, FALSE otherwise.
77 * Remark: The handle is obtained in the PENUMERATE_RECYCLEBIN_CALLBACK callback
78 */
79 BOOL WINAPI
80 DeleteFileHandleToRecycleBin(
81 IN HANDLE hDeletedFile);
82
83 /* Removes all elements contained in a recycle bin
84 * pszRoot: the name of the drive containing the recycle bin
85 * Returns TRUE if operation succeeded, FALSE otherwise.
86 * Remarks: 'pszRoot' can be NULL to mean 'all recycle bins'.
87 */
88 BOOL WINAPI
89 EmptyRecycleBinA(
90 IN LPCSTR pszRoot OPTIONAL);
91 BOOL WINAPI
92 EmptyRecycleBinW(
93 IN LPCWSTR pszRoot OPTIONAL);
94 #ifdef UNICODE
95 #define EmptyRecycleBin EmptyRecycleBinW
96 #else
97 #define EmptyRecycleBin EmptyRecycleBinA
98 #endif
99
100 /* Enumerate contents of a recycle bin.
101 * pszRoot: the name of the drive containing the recycle bin
102 * pFnCallback: callback function to be called for each deleted item found
103 * Context: some value which will be given back in the callback function
104 * Returns TRUE if operation succeeded, FALSE otherwise.
105 * Remarks: 'pszRoot' can be NULL to mean 'all recycle bins'.
106 */
107 BOOL WINAPI
108 EnumerateRecycleBinA(
109 IN LPCSTR pszRoot OPTIONAL,
110 IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
111 IN PVOID Context OPTIONAL);
112 BOOL WINAPI
113 EnumerateRecycleBinW(
114 IN LPCWSTR pszRoot OPTIONAL,
115 IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
116 IN PVOID Context OPTIONAL);
117 #ifdef UNICODE
118 #define EnumerateRecycleBin EnumerateRecycleBinW
119 #else
120 #define EnumerateRecycleBin EnumerateRecycleBinA
121 #endif
122
123 /* Gets details about a deleted file
124 * hDeletedFile: handle of the deleted file to get details about
125 * BufferSize: size of the 'FileDetails' buffer, in bytes
126 * FileDetails: if the function succeeded, contains details about the deleted file
127 * RequiredSize: contains the minimal buffer size required to get file information details
128 * Returns TRUE if operation succeeded, FALSE otherwise.
129 * Remark: The handle is obtained in the PENUMERATE_RECYCLEBIN_CALLBACK callback
130 */
131 BOOL WINAPI
132 GetDeletedFileDetailsA(
133 IN HANDLE hDeletedFile,
134 IN DWORD BufferSize,
135 IN OUT PDELETED_FILE_DETAILS_A FileDetails OPTIONAL,
136 OUT LPDWORD RequiredSize OPTIONAL);
137 BOOL WINAPI
138 GetDeletedFileDetailsW(
139 IN HANDLE hDeletedFile,
140 IN DWORD BufferSize,
141 IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL,
142 OUT LPDWORD RequiredSize OPTIONAL);
143 #ifdef UNICODE
144 #define GetDeletedFileDetails GetDeletedFileDetailsW
145 #else
146 #define GetDeletedFileDetails GetDeletedFileDetailsA
147 #endif
148
149 /* Get details about a whole recycle bin
150 * pszVolume:
151 * pulTotalItems:
152 * pulTotalSize
153 */
154 BOOL WINAPI
155 GetRecycleBinDetails(
156 IN LPCWSTR pszVolume OPTIONAL,
157 OUT ULARGE_INTEGER *pulTotalItems,
158 OUT ULARGE_INTEGER *pulTotalSize);
159
160 /* Restores a deleted file
161 * hDeletedFile: handle of the deleted file to restore
162 * Returns TRUE if operation succeeded, FALSE otherwise.
163 * Remarks: if the function succeeds, the handle is not valid anymore.
164 */
165 BOOL WINAPI
166 RestoreFile(
167 IN HANDLE hDeletedFile);
168
169 /* COM interface */
170
171 #undef INTERFACE
172 #define INTERFACE IRecycleBinFile
173
174 DECLARE_INTERFACE_(IRecycleBinFile, IUnknown)
175 {
176 BEGIN_INTERFACE
177
178 /* IUnknown methods */
179 STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
180 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
181 STDMETHOD_(ULONG, Release)(THIS) PURE;
182
183 /* IRecycleBinFile methods */
184 STDMETHOD(GetLastModificationTime)(THIS_ FILETIME *pLastModificationTime) PURE;
185 STDMETHOD(GetDeletionTime)(THIS_ FILETIME *pDeletionTime) PURE;
186 STDMETHOD(GetFileSize)(THIS_ ULARGE_INTEGER *pFileSize) PURE;
187 STDMETHOD(GetPhysicalFileSize)(THIS_ ULARGE_INTEGER *pPhysicalFileSize) PURE;
188 STDMETHOD(GetAttributes)(THIS_ DWORD *pAttributes) PURE;
189 STDMETHOD(GetFileName)(THIS_ SIZE_T BufferSize, LPWSTR Buffer, SIZE_T *RequiredSize) PURE;
190 STDMETHOD(Delete)(THIS) PURE;
191 STDMETHOD(Restore)(THIS) PURE;
192
193 END_INTERFACE
194 };
195
196 #undef INTERFACE
197 #define INTERFACE IRecycleBinEnumList
198
199 DECLARE_INTERFACE_(IRecycleBinEnumList, IUnknown)
200 {
201 BEGIN_INTERFACE
202
203 /* IUnknown methods */
204 STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
205 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
206 STDMETHOD_(ULONG, Release)(THIS) PURE;
207
208 /* IRecycleBinEnumList methods */
209 STDMETHOD(Next)(THIS_ DWORD celt, IRecycleBinFile **rgelt, DWORD *pceltFetched);
210 STDMETHOD(Skip)(THIS_ DWORD celt) PURE;
211 STDMETHOD(Reset)(THIS) PURE;
212
213 END_INTERFACE
214 };
215
216 #undef INTERFACE
217 #define INTERFACE IRecycleBin
218
219 DECLARE_INTERFACE_(IRecycleBin, IUnknown)
220 {
221 BEGIN_INTERFACE
222
223 /* IUnknown methods */
224 STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
225 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
226 STDMETHOD_(ULONG, Release)(THIS) PURE;
227
228 /* IRecycleBin methods */
229 STDMETHOD(DeleteFile)(THIS_ LPCWSTR szFileName);
230 STDMETHOD(EmptyRecycleBin)(THIS);
231 STDMETHOD(EnumObjects)(THIS_ IRecycleBinEnumList **ppEnumList);
232
233 END_INTERFACE
234 };
235
236 EXTERN_C const IID IID_IRecycleBinFile;
237 EXTERN_C const IID IID_IRecycleBinEnumList;
238 EXTERN_C const IID IID_IRecycleBin;
239
240 #if (!defined(__cplusplus) || defined(CINTERFACE)) && defined(COBJMACROS)
241 #define IRecycleBinFile_QueryInterface(This, riid, ppvObject) \
242 (This)->lpVtbl->QueryInterface(This, riid, ppvObject)
243 #define IRecycleBinFile_AddRef(This) \
244 (This)->lpVtbl->AddRef(This)
245 #define IRecycleBinFile_Release(This) \
246 (This)->lpVtbl->Release(This)
247 #define IRecycleBinFile_GetLastModificationTime(This, pLastModificationTime) \
248 (This)->lpVtbl->GetLastModificationTime(This, pLastModificationTime)
249 #define IRecycleBinFile_GetDeletionTime(This, pDeletionTime) \
250 (This)->lpVtbl->GetDeletionTime(This, pDeletionTime)
251 #define IRecycleBinFile_GetFileSize(This, pFileSize) \
252 (This)->lpVtbl->GetFileSize(This, pFileSize)
253 #define IRecycleBinFile_GetPhysicalFileSize(This, pPhysicalFileSize) \
254 (This)->lpVtbl->GetPhysicalFileSize(This, pPhysicalFileSize)
255 #define IRecycleBinFile_GetAttributes(This, pAttributes) \
256 (This)->lpVtbl->GetAttributes(This, pAttributes)
257 #define IRecycleBinFile_GetFileName(This, BufferSize, Buffer, RequiredSize) \
258 (This)->lpVtbl->GetFileName(This, BufferSize, Buffer, RequiredSize)
259 #define IRecycleBinFile_Delete(This) \
260 (This)->lpVtbl->Delete(This)
261 #define IRecycleBinFile_Restore(This) \
262 (This)->lpVtbl->Restore(This)
263
264 #define IRecycleBinEnumList_QueryInterface(This, riid, ppvObject) \
265 (This)->lpVtbl->QueryInterface(This, riid, ppvObject)
266 #define IRecycleBinEnumList_AddRef(This) \
267 (This)->lpVtbl->AddRef(This)
268 #define IRecycleBinEnumList_Release(This) \
269 (This)->lpVtbl->Release(This)
270 #define IRecycleBinEnumList_Next(This, celt, rgelt, pceltFetched) \
271 (This)->lpVtbl->Next(This, celt, rgelt, pceltFetched)
272 #define IRecycleBinEnumList_Skip(This, celt) \
273 (This)->lpVtbl->Skip(This, celt)
274 #define IRecycleBinEnumList_Reset(This) \
275 (This)->lpVtbl->Reset(This)
276
277 #define IRecycleBin_QueryInterface(This, riid, ppvObject) \
278 (This)->lpVtbl->QueryInterface(This, riid, ppvObject)
279 #define IRecycleBin_AddRef(This) \
280 (This)->lpVtbl->AddRef(This)
281 #define IRecycleBin_Release(This) \
282 (This)->lpVtbl->Release(This)
283 #define IRecycleBin_DeleteFile(This, szFileName) \
284 (This)->lpVtbl->DeleteFile(This, szFileName)
285 #define IRecycleBin_EmptyRecycleBin(This) \
286 (This)->lpVtbl->EmptyRecycleBin(This)
287 #define IRecycleBin_EnumObjects(This, ppEnumList) \
288 (This)->lpVtbl->EnumObjects(This, ppEnumList)
289 #endif
290
291 HRESULT WINAPI
292 GetDefaultRecycleBin(
293 IN LPCWSTR pszVolume OPTIONAL,
294 OUT IRecycleBin **pprb);
295
296 #ifdef __cplusplus
297 }
298 #endif