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