Rev 23 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
12 | daniel-mar | 1 | unit Main; |
2 | |||
3 | // TODO: Also include BC++ Versions |
||
4 | {$IFNDEF BCB} |
||
5 | {$DEFINE DEL1UP} |
||
6 | {$IFNDEF VER80} |
||
7 | {$DEFINE DEL2UP} |
||
8 | {$IFNDEF VER90} |
||
9 | {$DEFINE DEL3UP} |
||
10 | {$IFNDEF VER100} |
||
11 | {$DEFINE DEL4UP} |
||
12 | {$IFNDEF VER120} |
||
13 | {$DEFINE DEL5UP} |
||
14 | {$IFNDEF VER130} |
||
15 | {$DEFINE DEL6UP} |
||
16 | {...} |
||
17 | {$ENDIF} |
||
18 | {$ENDIF} |
||
19 | {$ENDIF} |
||
20 | {$ENDIF} |
||
21 | {$ENDIF} |
||
22 | {$ENDIF} |
||
23 | |||
24 | {$IFDEF DEL6UP} |
||
25 | {$WARN UNIT_PLATFORM OFF} |
||
26 | {$ENDIF} |
||
27 | |||
28 | interface |
||
29 | |||
30 | uses |
||
31 | Windows, SysUtils, Forms, Controls, StdCtrls, |
||
32 | ExtCtrls, Classes, Dialogs; |
||
33 | |||
34 | type |
||
35 | TMainForm = class(TForm) |
||
36 | openDialog: TOpenDialog; |
||
37 | outputMemo: TMemo; |
||
38 | topPanel: TPanel; |
||
39 | rightPanel: TPanel; |
||
40 | btnReadOwnRecyclers: TButton; |
||
41 | leftPanel: TPanel; |
||
42 | btnReadRecyclerFile: TButton; |
||
43 | outputPanel: TPanel; |
||
44 | saveDialog: TSaveDialog; |
||
45 | btnShowConfig: TButton; |
||
46 | btnSaveTextDump: TButton; |
||
47 | procedure btn_read_click(Sender: TObject); |
||
48 | procedure btn_readown_click(Sender: TObject); |
||
49 | procedure btnSaveTextDumpClick(Sender: TObject); |
||
50 | procedure btnShowConfigClick(Sender: TObject); |
||
51 | public |
||
52 | procedure ReadRecycler(filename: string); |
||
53 | end; |
||
54 | |||
55 | var |
||
56 | MainForm: TMainForm; |
||
57 | |||
58 | implementation |
||
59 | |||
60 | uses |
||
61 | RecyclerFunctions; |
||
62 | |||
63 | {$R *.dfm} |
||
64 | |||
65 | function _BoolToEnabledDisabled(b: boolean): string; |
||
66 | begin |
||
67 | if b then |
||
68 | result := 'Enabled' |
||
69 | else |
||
70 | result := 'Disabled'; |
||
71 | end; |
||
72 | |||
73 | function _BoolToYesNo(b: boolean): string; |
||
74 | begin |
||
75 | if b then |
||
76 | result := 'Yes' |
||
77 | else |
||
78 | result := 'No'; |
||
79 | end; |
||
80 | |||
81 | {$IFNDEF DEL6UP} |
||
82 | // Only available since Delphi 6 |
||
83 | function DirectoryExists(const directory: string): boolean; |
||
84 | var |
||
85 | attr: integer; |
||
86 | begin |
||
87 | attr := getfileattributes(pchar(directory)); |
||
88 | result := (attr <> -1) and (file_attribute_directory and attr <> 0); |
||
89 | end; |
||
90 | {$ENDIF} |
||
91 | |||
92 | procedure TMainForm.ReadRecycler(filename: string); |
||
93 | var |
||
94 | x: TStringList; |
||
95 | i: integer; |
||
96 | tmp, fn: string; |
||
97 | begin |
||
98 | outputMemo.Visible := false; |
||
99 | application.ProcessMessages; |
||
100 | |||
101 | if (uppercase(copy(extractfilename(filename), 0, 2)) = '$I') or |
||
102 | (uppercase(copy(extractfilename(filename), 0, 2)) = '$R') then |
||
103 | begin |
||
104 | outputMemo.Lines.Add('Reading directory:'); |
||
105 | tmp := extractfilepath(filename); |
||
106 | end |
||
107 | else |
||
108 | begin |
||
109 | tmp := filename; |
||
110 | if directoryexists(tmp) then |
||
111 | outputMemo.Lines.Add('Reading directory:') |
||
112 | else |
||
113 | outputMemo.Lines.Add('Reading file:'); |
||
114 | end; |
||
115 | |||
116 | outputMemo.Lines.Add(tmp); |
||
117 | outputMemo.lines.add(''); |
||
118 | |||
119 | if not RecyclerIsValid(filename) then |
||
120 | begin |
||
121 | outputMemo.lines.add('Recycler is not valid.'); |
||
122 | outputMemo.lines.add(''); |
||
123 | end |
||
124 | else |
||
125 | begin |
||
126 | x := TStringList.Create; |
||
127 | try |
||
128 | RecyclerListIndexes(filename, x); |
||
129 | if x.Count = 0 then |
||
130 | begin |
||
131 | outputMemo.lines.add('No items available.'); |
||
132 | outputMemo.lines.add(''); |
||
133 | end; |
||
134 | for i := 0 to x.Count - 1 do |
||
135 | begin |
||
136 | fn := RecyclerCurrentFilenameAndPath(tmp, x[i]); |
||
137 | outputMemo.lines.add(inttostr(i+1)+'. Entry'); |
||
138 | outputMemo.lines.add('# Unique ID: ' + changefileext(x[i], '')); |
||
139 | outputMemo.lines.add('# Recycler filename: '+fn); |
||
140 | |||
141 | if fileexists(fn) then |
||
142 | outputMemo.lines.add(' -> Found') |
||
143 | else |
||
144 | outputMemo.lines.add(' -> Not found'); |
||
145 | |||
146 | {$IFDEF DEL6UP} |
||
147 | outputMemo.lines.add('# Deleted: '+ |
||
148 | datetimetostr(RecyclerGetDateTime(tmp, x[i]))); |
||
149 | {$ELSE} |
||
150 | outputMemo.lines.add('# Deleted: You have to compile this demo with Delphi 6 or higher.'); |
||
151 | {$ENDIF} |
||
152 | outputMemo.lines.add('# Original filename: '+ |
||
153 | RecyclerGetSource(tmp, x[i])); |
||
154 | outputMemo.lines.add('# Unicode filename: '+ |
||
155 | RecyclerGetSourceUnicode(tmp, x[i])); |
||
156 | outputMemo.lines.add('# Source device: '+ |
||
157 | RecyclerGetSourceDrive(tmp, x[i])); |
||
158 | outputMemo.lines.add('# Original size on disk: '+ |
||
159 | inttostr(RecyclerOriginalSize(tmp, x[i]))+' Byte'); |
||
160 | outputMemo.lines.add(''); |
||
161 | end; |
||
162 | finally |
||
163 | x.Free; |
||
164 | end; |
||
165 | end; |
||
166 | |||
167 | outputMemo.Visible := true; |
||
168 | end; |
||
169 | |||
170 | procedure TMainForm.btn_read_click(Sender: TObject); |
||
171 | begin |
||
172 | if openDialog.Execute() then |
||
173 | begin |
||
174 | outputMemo.Clear; |
||
175 | ReadRecycler(openDialog.filename); |
||
176 | end; |
||
177 | end; |
||
178 | |||
179 | procedure TMainForm.btn_readown_click(Sender: TObject); |
||
180 | var |
||
181 | x, sl: TStringList; |
||
182 | i, j: integer; |
||
183 | somethingfound: boolean; |
||
184 | begin |
||
185 | outputMemo.Visible := false; |
||
186 | try |
||
187 | application.ProcessMessages; |
||
188 | |||
189 | outputMemo.Clear; |
||
190 | x := TStringList.Create; |
||
191 | try |
||
192 | RecyclerGetAllRecyclerDrives(x); |
||
193 | somethingfound := false; |
||
194 | if x.Count > 0 then |
||
195 | begin |
||
196 | for i := 0 to x.Count - 1 do |
||
197 | begin |
||
198 | // ReadRecycler(RecyclerGetPath(x[i][1]), true); |
||
199 | |||
200 | sl := TStringList.Create; |
||
201 | try |
||
202 | RecyclerGetInfofiles(x[i][1], true, sl); |
||
203 | if sl.Count > 0 then |
||
204 | begin |
||
205 | for j := 0 to sl.Count - 1 do |
||
206 | begin |
||
207 | ReadRecycler(sl.Strings[j]); |
||
208 | somethingfound := true; |
||
209 | end; |
||
210 | end; |
||
211 | finally |
||
212 | sl.Free; |
||
213 | end; |
||
214 | end; |
||
215 | end; |
||
216 | if not somethingfound then |
||
217 | begin |
||
218 | outputMemo.lines.add('No recyclers found.'); |
||
219 | outputMemo.lines.add(''); |
||
220 | end; |
||
221 | finally |
||
222 | x.Free; |
||
223 | end; |
||
224 | finally |
||
225 | outputMemo.Visible := true; |
||
226 | end; |
||
227 | end; |
||
228 | |||
229 | procedure TMainForm.btnSaveTextDumpClick(Sender: TObject); |
||
230 | begin |
||
231 | if saveDialog.Execute then |
||
232 | begin |
||
233 | outputMemo.Lines.SaveToFile(saveDialog.FileName); |
||
234 | end; |
||
235 | end; |
||
236 | |||
237 | procedure TMainForm.btnShowConfigClick(Sender: TObject); |
||
238 | var |
||
239 | d: char; |
||
240 | sl: TStringList; |
||
241 | i: integer; |
||
242 | begin |
||
243 | outputMemo.Visible := false; |
||
244 | try |
||
245 | application.ProcessMessages; |
||
246 | |||
247 | outputMemo.Clear; |
||
248 | |||
249 | outputMemo.Lines.Add(RecyclerLibraryVersion); |
||
250 | |||
251 | outputMemo.Lines.Add(''); |
||
22 | daniel-mar | 252 | outputMemo.Lines.Add('= Possible recyclers (fixed drives) ='); |
253 | outputMemo.Lines.Add(''); |
||
254 | |||
255 | for d := 'A' to 'Z' do |
||
256 | begin |
||
257 | outputMemo.Lines.Add('Recycler is possible at drive '+d+': ' + _BoolToYesNo(RecyclerIsPossible(d))); |
||
258 | end; |
||
259 | |||
260 | outputMemo.Lines.Add(''); |
||
23 | daniel-mar | 261 | outputMemo.Lines.Add('= Valid recyclers ='); |
262 | outputMemo.Lines.Add(''); |
||
263 | |||
264 | for d := 'A' to 'Z' do |
||
265 | begin |
||
266 | outputMemo.Lines.Add('Drive '+d+': ' + _BoolToYesNo(RecyclerIsValid(d))); |
||
267 | end; |
||
268 | |||
269 | outputMemo.Lines.Add(''); |
||
12 | daniel-mar | 270 | outputMemo.Lines.Add('= Current status ='); |
271 | outputMemo.Lines.Add(''); |
||
272 | |||
273 | if RecyclerQueryFunctionAvailable then |
||
274 | begin |
||
275 | outputMemo.Lines.Add('GLOBAL Empty = ' + _BoolToYesNo(RecyclerIsEmpty)); |
||
276 | outputMemo.Lines.Add('GLOBAL Number of items = ' + IntToStr(RecyclerGetNumItems)); |
||
277 | outputMemo.Lines.Add('GLOBAL Size = ' + IntToStr(RecyclerGetSize) + ' Bytes'); |
||
278 | for d := 'A' to 'Z' do |
||
279 | begin |
||
24 | daniel-mar | 280 | if not RecyclerIsPossible(d) then Continue; // Important since Windows Vista throws Exceptions! |
12 | daniel-mar | 281 | outputMemo.Lines.Add('Drive '+d+' Empty = ' + _BoolToYesNo(RecyclerIsEmpty(d))); |
282 | outputMemo.Lines.Add('Drive '+d+' Number of items = ' + IntToStr(RecyclerGetNumItems(d))); |
||
283 | outputMemo.Lines.Add('Drive '+d+' Size = ' + IntToStr(RecyclerGetSize(d)) + ' Bytes'); |
||
284 | end; |
||
285 | end |
||
286 | else |
||
287 | begin |
||
288 | outputMemo.Lines.Add('Empty, Number of items, Size:'); |
||
289 | outputMemo.Lines.Add(' Functionality not working with your operating system.'); |
||
290 | end; |
||
291 | |||
292 | outputMemo.Lines.Add(''); |
||
293 | outputMemo.Lines.Add('= Name and Infotips ='); |
||
294 | outputMemo.Lines.Add(''); |
||
295 | |||
296 | outputMemo.Lines.Add('Name: '+RecyclerGetName()); |
||
297 | outputMemo.Lines.Add('Info Tip: '+RecyclerGetInfoTip()); |
||
298 | outputMemo.Lines.Add('Intro Text: '+RecyclerGetIntroText()); |
||
299 | outputMemo.Lines.Add('Class-ID: '+RecyclerGetCLSID()); |
||
300 | |||
301 | outputMemo.Lines.Add(''); |
||
302 | outputMemo.Lines.Add('= Icons ='); |
||
303 | outputMemo.Lines.Add(''); |
||
304 | |||
305 | outputMemo.Lines.Add('Default Icon: '+RecyclerGetDefaultIconString()); |
||
306 | if RecyclerQueryFunctionAvailable then |
||
307 | begin |
||
308 | outputMemo.Lines.Add('Current Icon (Empty / Full): '+RecyclerGetCurrentIconString()); |
||
309 | end |
||
310 | else |
||
311 | begin |
||
312 | outputMemo.Lines.Add('Current Icon (Empty / Full):'); |
||
313 | outputMemo.Lines.Add(' Functionality not working with your operating system.'); |
||
314 | end; |
||
315 | outputMemo.Lines.Add('Full Icon: '+RecyclerGetFullIconString()); |
||
316 | outputMemo.Lines.Add('Empty Icon: '+RecyclerGetEmptyIconString()); |
||
317 | |||
318 | outputMemo.Lines.Add(''); |
||
319 | outputMemo.Lines.Add('= Events ='); |
||
320 | outputMemo.Lines.Add(''); |
||
321 | |||
322 | outputMemo.Lines.Add('Empty Event Name: '+RecyclerEmptyEventGetName()); |
||
323 | outputMemo.Lines.Add('Empty Event Current Sound: '+RecyclerEmptyEventGetCurrentSound()); |
||
324 | outputMemo.Lines.Add('Empty Event Default Sound: '+RecyclerEmptyEventGetDefaultSound()); |
||
325 | |||
326 | sl := TStringList.Create; |
||
327 | try |
||
328 | RecyclerEmptyEventGetSoundCategories(sl); |
||
329 | for i := 0 to sl.Count - 1 do |
||
330 | begin |
||
331 | outputMemo.Lines.Add(Format('Event "%s" = %s', [sl.Strings[i], RecyclerEmptyEventGetSound(sl.Strings[i])])); |
||
332 | end; |
||
333 | finally |
||
334 | sl.Free; |
||
335 | end; |
||
336 | |||
337 | outputMemo.Lines.Add(''); |
||
338 | outputMemo.Lines.Add('= Nuke on Delete ='); |
||
339 | outputMemo.Lines.Add(''); |
||
340 | |||
17 | daniel-mar | 341 | outputMemo.Lines.Add('Group policy setting: ' + GPBoolToString(RecyclerGroupPolicyNoRecycleFiles)); |
342 | outputMemo.Lines.Add('Global settings selected: ' + _BoolToYesNo(RecyclerHasGlobalSettings)); |
||
12 | daniel-mar | 343 | outputMemo.Lines.Add('Global setting: ' + _BoolToEnabledDisabled(RecyclerGlobalIsNukeOnDelete())); |
344 | for d := 'A' to 'Z' do |
||
345 | begin |
||
22 | daniel-mar | 346 | // if not RecyclerIsPossible(d) then Continue; |
17 | daniel-mar | 347 | outputMemo.Lines.Add('Individual setting for drive '+d+': ' + _BoolToEnabledDisabled(RecyclerSpecificIsNukeOnDelete(d))); |
348 | outputMemo.Lines.Add('Auto determinated setting for drive '+d+' (includes group policy and global setting): ' + _BoolToEnabledDisabled(RecyclerIsNukeOnDeleteAutoDeterminate(d))); |
||
12 | daniel-mar | 349 | end; |
350 | |||
351 | outputMemo.Lines.Add(''); |
||
352 | outputMemo.Lines.Add('= Usage Percent ='); |
||
353 | outputMemo.Lines.Add(''); |
||
354 | |||
17 | daniel-mar | 355 | outputMemo.Lines.Add('Group policy setting: ' + IntToStr(RecyclerGroupPolicyRecycleBinSize)); |
356 | outputMemo.Lines.Add('Global settings selected: ' + _BoolToYesNo(RecyclerHasGlobalSettings)); |
||
12 | daniel-mar | 357 | outputMemo.Lines.Add('Global setting: ' + IntToStr(RecyclerGlobalGetPercentUsage())); |
358 | for d := 'A' to 'Z' do |
||
359 | begin |
||
22 | daniel-mar | 360 | // if not RecyclerIsPossible(d) then Continue; |
12 | daniel-mar | 361 | outputMemo.Lines.Add('Setting for drive '+d+': ' + IntToStr(RecyclerSpecificGetPercentUsage(d))); |
21 | daniel-mar | 362 | outputMemo.Lines.Add('Auto determinated setting for drive '+d+' (includes group policy and global setting): ' + IntToStr(RecyclerGetPercentUsageAutoDeterminate(d))); |
12 | daniel-mar | 363 | end; |
364 | |||
365 | outputMemo.Lines.Add(''); |
||
366 | outputMemo.Lines.Add('= Confirmation Dialog ='); |
||
367 | outputMemo.Lines.Add(''); |
||
368 | |||
17 | daniel-mar | 369 | outputMemo.Lines.Add('Setting in Shell: ' + _BoolToEnabledDisabled(RecyclerShellStateConfirmationDialogEnabled())); |
370 | outputMemo.Lines.Add('Setting in Group Policy: ' + GPBoolToString(RecyclerGroupPolicyConfirmFileDelete())); |
||
371 | outputMemo.Lines.Add('Resulting Setting (Group policy before Shell): ' + _BoolToEnabledDisabled(RecyclerConfirmationDialogEnabled())); |
||
12 | daniel-mar | 372 | finally |
373 | outputMemo.Visible := true; |
||
374 | end; |
||
375 | end; |
||
376 | |||
377 | end. |