forked from bgbennyboy/USB-Disk-Ejector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuDiskEjectOptions.pas
630 lines (533 loc) · 23.4 KB
/
uDiskEjectOptions.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2017 Bennyboy
Http://quickandeasysoftware.net
******************************************************
}
{
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
{
Based on uObjetos.pas by Sebastián Mayorá
(DelphiHelper@Yahoo.com.ar)
For more information see http://delphi.about.com/library/bluc/text/uc090302a.htm
}
unit uDiskEjectOptions;
interface
uses
Classes, Sysutils, forms, inifiles, System.Contnrs, JCLFileUtils, JCLSysInfo, JCLStrings,
uDiskEjectConst, uCustomHotKeyManager, uCardReaderManager,
dialogs;
type
TOptions = class (TComponent)
private
fOptionsIniPath: string; //Filename to store the ini
fIniFile: TMemIniFile;
//Internal properties
fUseWindowsNotifications: boolean; //Show windows' eject message rather than the apps.
//fShowNoEjectMessage: boolean; //Show no eject message at all
fPreserveWindowLocation: boolean;
fPreserveWindowSize: boolean;
fAutoResize: boolean; //Automatically resize to show all drives
fWindowHeight: integer;
fWindowWidth: integer;
fWindowLeftPos: integer;
fWindowTopPos: integer;
fStartAppMinimised: boolean;
fCloseToTray: boolean; //Cross/exit button makes app minimize to tray rather than exit
fMinimizeToTray: boolean;
fBalloonMessages: boolean; //Stops balloon messages from appearing when the program is run in GUI mode
fCardPolling: boolean; //If devices are polled every x seconds to see if they have card media loaded
fCardPollingInterval: integer;
fShowCardReaders: boolean;
fAfterEject: integer; //After a successful eject do 0 - nothing, 1 - exit, 2 - minimize
fAudioNotifications: boolean;
fHideCardReadersWithNoMedia: boolean;
fCloseRunningApps_Ask: boolean;
fCloseRunningApps_Force: boolean;
fMinimizeWithEsc: boolean;
fSnapTo: integer;
fMaxWidth: integer;
fShowPartitionsAsOne: boolean;
fHotKeys: TCustomHotKeyManager;
fCardReaders: TCardReaderManager;
//function GetCommandLine_UseWindowsNotifications: boolean;
function GetMobileMode: boolean;
function GetCommandLine_NoSave: boolean;
function GetCommandLine_RemoveLetter: boolean;
function GetCommandLine_RemoveLabel: boolean;
function GetCommandLine_RemoveMountPoint: boolean;
function GetCommandLine_RemoveName: boolean;
function GetCommandLine_RemoveThis: boolean;
function GetCommandLine_EjectCard: boolean;
function GetCommandLine_CfgDir: boolean;
//function GetCommandLine_CloseApps: boolean;
//function GetCommandLine_CloseAppsForce: boolean;
//function GetCommandLine_Param_UseWindowsNotifications: string;
function GetCommandLine_Param_RemoveLetter: string;
function GetCommandLine_Param_RemoveLabel: string;
function GetCommandLine_Param_RemoveMountPoint: string;
function GetCommandLine_Param_RemoveName: string;
function GetCommandLine_Param_CfgDir: string;
//function GetCommandLine_Param_CloseApps: string;
//function GetCommandLine_Param_CloseAppsForce: string;
function FindParamIndex(Param: string): integer;
function GetIniPath: string;
public
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
procedure ReadConfig;
procedure SaveConfig;
procedure RebuildHotkeys;
procedure RebuildCardReaders;
//These arent Saved
property CommandLine_NoSave: boolean read GetCommandLine_NoSave;
property CommandLine_RemoveThis: boolean read GetCommandLine_RemoveThis;
property CommandLine_RemoveLetter: boolean read GetCommandLine_RemoveLetter;
property CommandLine_RemoveLabel: boolean read GetCommandLine_RemoveLabel;
property CommandLine_RemoveMountPoint: boolean read GetCommandLine_RemoveMountPoint;
property CommandLine_RemoveName: boolean read GetCommandLine_RemoveName;
property CommandLine_EjectCard: boolean read GetCommandLine_EjectCard;
property CommandLine_CFGDir: boolean read GetCommandLine_CfgDir;
//property CommandLine_CloseApps: boolean read GetCommandLine_CloseApps;
// property CommandLine_CloseAppsForce: boolean read GetCommandLine_CloseAppsForce;
//property CommandLine_UseWindowsNotifications: boolean read GetCommandLine_UseWindowsNotifications;
property InMobileMode: boolean read GetMobileMode; //if running from temp folder
property CommandLine_Param_RemoveLetter: string read GetCommandLine_Param_RemoveLetter;
property CommandLine_Param_RemoveLabel: string read GetCommandLine_Param_RemoveLabel;
property CommandLine_Param_RemoveMountPoint: string read GetCommandLine_Param_RemoveMountPoint;
property CommandLine_Param_RemoveName: string read GetCommandLine_Param_RemoveName;
property CommandLine_Param_CfgDir: string read GetCommandLine_Param_CfgDir;
property IniPath: string read GetIniPath;
//property CommandLine_Param_CloseApps: string read GetCommandLine_Param_CloseApps;
//property CommandLine_Param_CloseAppsForce: string read GetCommandLine_Param_CloseAppsForce;
//property CommandLine_Param_UseWindowsNotifications: string read GetCommandLine_Param_UseWindowsNotifications; //returns the text switch for use with relaunching the program
//These are saved
property UseWindowsNotifications : boolean read fUseWindowsNotifications write fUseWindowsNotifications;
//property ShowNoEjectMessage : boolean read fShowNoEjectMessage write fShowNoEjectMessage;
property PreserveWindowLocation : boolean read fPreserveWindowLocation write fPreserveWindowLocation;
property PreserveWindowSize : boolean read fPreserveWindowSize write fPreserveWindowSize;
property AutoResize : boolean read fAutoResize write fAutoResize;
property StartAppMinimised : boolean read fStartAppMinimised write fStartAppMinimised;
property CloseToTray : boolean read fCloseToTray write fCloseToTray;
property MinimizeToTray : boolean read fMinimizeToTray write fMinimizeToTray;
property BalloonMessages : boolean read fBalloonMessages write fBalloonMessages;
property CloseRunningApps_Ask : boolean read fCloseRunningApps_Ask write fCloseRunningApps_Ask;
property CloseRunningApps_Force : boolean read fCloseRunningApps_Force write fCloseRunningApps_Force;
property AudioNotifications : boolean read fAudioNotifications write fAudioNotifications;
property HideCardReadersWithNoMedia : boolean read fHideCardReadersWithNoMedia write fHideCardReadersWithNoMedia;
property MinimizeWithEsc : boolean read fMinimizeWithEsc write fMinimizeWithEsc;
property WindowHeight : integer read fWindowHeight write fWindowHeight;
property WindowWidth : integer read fWindowWidth write fWindowWidth;
property WindowLeftPos : integer read fWindowLeftPos write fWindowLeftPos;
property WindowTopPos : integer read fWindowTopPos write fWindowTopPos;
property ShowPartitionsAsOne : boolean read fShowPartitionsAsOne write fShowPartitionsAsOne;
property ShowCardReaders : boolean read fShowCardReaders write fShowCardReaders;
property CardPolling : boolean read fCardPolling write fCardPolling;
property CardPollingInterval : integer read fCardPollingInterval write fCardPollingInterval;
property AfterEject : integer read fAfterEject write fAfterEject;
property SnapTo : integer read fSnapTo write fSnapTo;
property MaxWidth : integer read fMaxWidth write fMaxWidth;
property HotKeys : TCustomHotKeyManager read fHotKeys write fHotKeys;
property CardReaders : TCardReaderManager read fCardReaders write fCardReaders;
end;
var
Options: TOptions;
implementation
constructor TOptions.Create(aOwner: TComponent);
begin
inherited Create(AOWner);
{if CommandLine_NoSave then
fOptionsFilename:=''
else}
//Default filepath
fOptionsIniPath:= ExtractFilePath(ParamStr(0)) + str_Ini_FileName;
//User specified different path for ini
if CommandLine_Param_CfgDir > '' then
//In the main dpr we check if this path is valid and warn and exit the program if its not.
fOptionsIniPath := IncludeTrailingPathDelimiter(CommandLine_Param_CfgDir) + str_Ini_FileName
end;
destructor TOptions.Destroy;
begin
//SaveConfig
if fIniFile <> nil then
fIniFile.Free;
inherited Destroy;
end;
procedure TOptions.ReadConfig;
begin
try
fIniFile:=TMemIniFile.Create(fOptionsIniPath);
fUseWindowsNotifications:= fIniFile.ReadBool('Preferences', 'ShowWindowsEjectMessage', false);
//fShowNoEjectMessage:= fIniFile.ReadBool('Preferences', 'ShowNoEjectMessage', true);
fPreserveWindowLocation:= fIniFile.ReadBool('Preferences', 'PreserveWindowLocation', false);
fPreserveWindowSize:= fIniFile.ReadBool('Preferences', 'PreserveWindowSize', false);
fAutoResize:= fIniFile.ReadBool('Preferences', 'AutoResize', true);
fStartAppMinimised:= fIniFile.ReadBool('Preferences', 'StartAppMinimised', false);
fCloseToTray:= fIniFile.ReadBool('Preferences', 'CloseToTray', false);
fMinimizeToTray:= fIniFile.ReadBool('Preferences', 'MinimizeToTray', true);
fBalloonMessages:= fIniFile.ReadBool('Preferences', 'BalloonMessages', true);
fCardPolling:= fIniFile.ReadBool('Preferences', 'CardPolling', true);
fCloseRunningApps_Ask:= fIniFile.ReadBool('Preferences', 'CloseRunningApps', false);
fCloseRunningApps_Force:= fIniFile.ReadBool('Preferences', 'ForceAppsClose', false);
fAudioNotifications:= fIniFile.ReadBool('Preferences', 'AudioNotifications', false);
fShowPartitionsAsOne:= fIniFile.ReadBool('Preferences', 'ShowPartitionsAsOne', false);
fHideCardReadersWithNoMedia:= fIniFile.ReadBool('Preferences', 'HideCardReadersWithNoMedia', true);
fShowCardReaders:= fIniFile.ReadBool('Preferences', 'ShowCardReaders', true);
fMinimizeWithEsc:= fIniFile.ReadBool('Preferences', 'MinimizeWithEsc', true);
fAfterEject:= fIniFile.ReadInteger('Preferences', 'AfterEject', 0);
fCardPollingInterval:= fIniFile.ReadInteger('Preferences', 'CardPollingInterval', 5000);
fMaxWidth:= fIniFile.ReadInteger('Preferences', 'MaxWidth', 0);
fWindowHeight:= fIniFile.ReadInteger('Preferences', 'WindowHeight', 233);
fWindowWidth:= fIniFile.ReadInteger('Preferences', 'WindowWidth', 345);
fWindowLeftPos:= fIniFile.ReadInteger('Preferences', 'WindowLeftPos', 200);
fWindowTopPos:= fIniFile.ReadInteger('Preferences', 'WindowTopPos', 200);
fSnapTo:= fIniFile.ReadInteger('Preferences', 'SnapTo', 1);
except
//Report error - cant find options file
end
end;
procedure TOptions.SaveConfig;
var
i: integer;
break: boolean;
begin
if CommandLine_NoSave then exit;
fIniFile.WriteBool('Preferences', 'ShowWindowsEjectMessage', fUseWindowsNotifications);
//fIniFile.WriteBool('Preferences', 'ShowNoEjectMessage', fShowNoEjectMessage);
fIniFile.WriteBool('Preferences', 'PreserveWindowLocation', fPreserveWindowLocation);
fIniFile.WriteBool('Preferences', 'PreserveWindowSize', fPreserveWindowSize);
fIniFile.WriteBool('Preferences', 'AutoResize', fAutoResize);
fIniFile.WriteBool('Preferences', 'StartAppMinimised', fStartAppMinimised);
fIniFile.WriteBool('Preferences', 'CloseToTray', fCloseToTray);
fIniFile.WriteBool('Preferences', 'MinimizeToTray', fMinimizeToTray);
fIniFile.WriteBool('Preferences', 'BalloonMessages', fBalloonMessages);
fIniFile.WriteBool('Preferences', 'CardPolling', fCardPolling);
fIniFile.WriteBool('Preferences', 'CloseRunningApps', fCloseRunningApps_Ask);
fIniFile.WriteBool('Preferences', 'ForceAppsClose', fCloseRunningApps_Force);
fIniFile.WriteBool('Preferences', 'AudioNotifications', fAudioNotifications);
fIniFile.WriteBool('Preferences', 'ShowPartitionsAsOne', fShowPartitionsAsOne);
fIniFile.WriteBool('Preferences', 'HideCardReadersWithNoMedia', fHideCardReadersWithNoMedia);
fIniFile.WriteBool('Preferences', 'ShowCardReaders', fShowCardReaders);
fIniFile.WriteBool('Preferences', 'MinimizeWithEsc', fMinimizeWithEsc);
fIniFile.WriteInteger('Preferences', 'AfterEject', fAfterEject);
fIniFile.WriteInteger('Preferences', 'CardPollingInterval', fCardPollingInterval);
fIniFile.WriteInteger('Preferences', 'MaxWidth', fMaxWidth);
fIniFile.WriteInteger('Preferences', 'WindowHeight', fWindowHeight);
fIniFile.WriteInteger('Preferences', 'WindowWidth', fWindowWidth);
fIniFile.WriteInteger('Preferences', 'WindowLeftPos', fWindowLeftPos);
fIniFile.WriteInteger('Preferences', 'WindowTopPos', fWindowTopPos);
fIniFile.WriteInteger('Preferences', 'SnapTo', fSnapTo);
//First find and delete any existing hotkeys in the ini file
break:=false;
i:=0;
while break = false do
begin
if fIniFile.SectionExists('Hotkey' + inttostr(i)) then
fIniFile.EraseSection('Hotkey' + inttostr(i))
else
break:=true;
inc(i);
end;
//Then save no of hotkeys and the hotkeys sections
if fHotKeys <> nil then
begin
if fHotKeys.HotKeys.Count > 0 then
fIniFile.WriteInteger('Hotkeys', 'NumHotkeys', fHotKeys.HotKeys.Count)
else
fIniFile.WriteInteger('Hotkeys', 'NumHotkeys', 0);
for I := 0 to fHotKeys.HotKeys.Count - 1 do
begin
fIniFile.WriteInteger('Hotkey' + inttostr(i), 'Hotkey',
TCustomHotKey(fHotKeys.HotKeys[i]).HotKey);
fIniFile.WriteInteger('Hotkey' + inttostr(i), 'HotKeyType',
Integer(TCustomHotKey(fHotKeys.HotKeys[i]).HotKeyType));
fIniFile.WriteString('Hotkey' + inttostr(i), 'HotKeyParam',
TCustomHotKey(fHotKeys.HotKeys[i]).HotKeyParam);
end;
end
else
fIniFile.WriteInteger('Hotkeys', 'NumHotkeys', 0);
//First find and delete any existing Card Readers in the ini file
break:=false;
i:=0;
while break = false do
begin
if fIniFile.SectionExists('Cardreader' + inttostr(i)) then
fIniFile.EraseSection('Cardreader' + inttostr(i))
else
break:=true;
inc(i);
end;
//Then save no of CardReaders and the different sections
if fHotKeys <> nil then
begin
if fCardReaders.CardReadersCount > 0 then
fIniFile.WriteInteger('Cardreaders', 'NumCardreaders', fCardReaders.CardReadersCount)
else
fIniFile.WriteInteger('Cardreaders', 'NumCardreaders', 0);
for I := 0 to fCardReaders.CardReadersCount - 1 do
begin
fIniFile.WriteString('Cardreader' + inttostr(i), 'VendorID',
fCardReaders.CardReaders[i].VendorID) ;
fIniFile.WriteString('Cardreader' + inttostr(i), 'ProductID',
fCardReaders.CardReaders[i].ProductID);
fIniFile.WriteString('Cardreader' + inttostr(i), 'ProductRevision',
fCardReaders.CardReaders[i].ProductRevision);
end;
end
else
fIniFile.WriteInteger('Cardreaders', 'NumCardreaders', 0);
fIniFile.UpdateFile;
end;
procedure TOptions.RebuildCardReaders;
var
numCardReaders, i: integer;
begin
if fCardReaders = nil then exit;
numCardReaders:=fIniFile.ReadInteger('Cardreaders', 'NumCardreaders', 0);
if numCardReaders = 0 then exit;
for I := 0 to numCardReaders - 1 do
begin
fCardReaders.AddCardReader( fIniFile.ReadString('Cardreader' + inttostr(i), 'VendorID', ''),
fIniFile.ReadString('Cardreader' + inttostr(i), 'ProductID', ''),
fIniFile.ReadString('Cardreader' + inttostr(i), 'ProductRevision', '')
);
end;
end;
procedure TOptions.RebuildHotkeys;
var
numHotKeys, i: integer;
begin
if fHotKeys = nil then exit;
numHotkeys:=fIniFile.ReadInteger('Hotkeys', 'NumHotkeys', 0);
if numHotKeys = 0 then exit;
for I := 0 to numHotKeys - 1 do
begin
fHotKeys.AddHotKey(
fIniFile.ReadInteger('Hotkey' + inttostr(i), 'Hotkey', 0),
TCustomHotkeyAction(fIniFile.ReadInteger('Hotkey' + inttostr(i), 'HotKeyType', 0)),
fIniFile.ReadString('Hotkey' + inttostr(i), 'HotKeyParam', '')
);
end;
end;
{****************************Command Line Functions****************************}
{function TOptions.GetCommandLine_CloseApps: boolean;
begin
if FindCmdLineSwitch('CLOSEAPPS', true) or FindCmdLineSwitch('CLOSEAPPSFORCE', true) then
result:=true
else
result:=false
end;
function TOptions.GetCommandLine_CloseAppsForce: boolean;
begin
if FindCmdLineSwitch('CLOSEAPPSFORCE', true) then
result:=true
else
result:=false
end;}
function TOptions.GetCommandLine_RemoveMountPoint: boolean;
begin
if FindCmdLineSwitch('REMOVEMOUNTPOINT', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_EjectCard: boolean;
begin
if FindCmdLineSwitch('EJECTCARD', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_CfgDir: boolean;
begin
if FindCmdLineSwitch('CFGDIR', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_NoSave: boolean;
begin
if FindCmdLineSwitch('NOSAVE', true) then
result:=true
else
result:=false
end;
function TOptions.GetCommandLine_RemoveLabel: boolean;
begin
if FindCmdLineSwitch('REMOVELABEL', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_RemoveLetter: boolean;
begin
if FindCmdLineSwitch('REMOVELETTER', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_RemoveName: boolean;
begin
if FindCmdLineSwitch('REMOVENAME', true) then
result:=true
else
result:=false;
end;
function TOptions.GetCommandLine_RemoveThis: boolean;
begin
if FindCmdLineSwitch('REMOVETHIS', true) then
result:=true
else
result:=false;
end;
function TOptions.GetIniPath: string;
begin
result := ExtractFilePath( fOptionsIniPath );
end;
{function TOptions.GetCommandLine_UseWindowsNotifications: boolean;
begin
if FindCmdLineSwitch('USEWINDOWSNOTIFICATIONS', true) then
result:=true
else
result:=false
end;}
function TOptions.GetCommandLine_Param_CfgDir: string;
var
intTemp: integer;
begin
//First find what number param the switch is
intTemp:=FindParamIndex('/CFGDIR');
if intTemp <> -1 then
result:=ParamStr(intTemp + 1)
else
result:='';
end;
function TOptions.GetCommandLine_Param_RemoveLabel: string;
var
intTemp: integer;
begin
intTemp:=FindParamIndex('/REMOVELABEL');
if (intTemp <> -1) and (ParamCount >= intTemp + 1) then
begin
result:=Uppercase(ParamStr(intTemp + 1));
end
else
result:='';
end;
function TOptions.GetCommandLine_Param_RemoveLetter: string;
var
intTemp: integer;
tempParam: string;
begin
//Get the params for removeletter and removename
//It should be the param straight after the /whatever switch
//So first find what number param the switch is
intTemp:=FindParamIndex('/REMOVELETTER');
if (intTemp <> -1) and (ParamCount >= intTemp + 1) then
begin
tempParam:=ParamStr(intTemp + 1);
result:=Uppercase(tempParam[1]); //Just return the letter
end
else
result:='';
end;
function TOptions.GetCommandLine_Param_RemoveMountPoint: string;
var
intTemp: integer;
tempParam: string;
begin
//First find what number param the switch is
intTemp:=FindParamIndex('/REMOVEMOUNTPOINT');
if (intTemp <> -1) and (ParamCount >= intTemp + 1) then
begin
tempParam:=ParamStr(intTemp + 1); //Paramstr automatically parses out speech marks
tempParam:=Trim(TempParam); //Remove trailing spaces
if length(tempParam) = 1 then //Its a drive letter on its own
result:=IncludeTrailingPathDelimiter(tempParam + ':')
else
result:=IncludeTrailingPathDelimiter(tempParam);
end
else
result:='';
//Showmessage('command line param ' + result);
end;
function TOptions.GetCommandLine_Param_RemoveName: string;
var
intTemp: integer;
begin
//First find what number param the switch is
intTemp:=FindParamIndex('/REMOVENAME');
if intTemp <> -1 then
result:=ParamStr(intTemp + 1)
else
result:='';
end;
{function TOptions.GetCommandLine_Param_UseWindowsNotifications: string;
begin
if CommandLine_UseWindowsNotifications then
result:='/USEWINDOWSNOTIFICATIONS '
else
result:='';
end;
function TOptions.GetCommandLine_Param_CloseApps: string;
begin
if CommandLine_CloseApps then
result:='/CLOSEAPPS '
else
result:='';
end;
function TOptions.GetCommandLine_Param_CloseAppsForce: string;
begin
if CommandLine_CloseAppsForce then
result:='/CLOSEAPPSFORCE '
else
result:='';
end;}
function TOptions.GetMobileMode: boolean;
begin
//Check if running from temp folder
if IncludeTrailingPathDelimiter(PathGetShortName(extractfilepath(application.ExeName))) = IncludeTrailingPathDelimiter( pathgetshortname(GetWindowsTempFolder) ) then
result:=true
else
result:=false;
end;
function TOptions.FindParamIndex(Param: string): integer;
var //Remember to include / in param when calling this, since ParamStr returns the /
i: integer;
begin
result:=-1;
for i := 1 to ParamCount do
begin
if Uppercase(Param) = Uppercase(ParamStr(i)) then
begin
result:=i;
break;
end;
end;
end;
{******************************************************************************}
initialization
{-----------------------------------------------------------------------------
Creating the object in this section allow us using it from anywhere and anytime.
Even from .DPR file and before forms creation.
Object Options is available from the beginning of the application
-----------------------------------------------------------------------------}
Options := TOptions.Create(nil);
Options.ReadConfig;
finalization
//If we create it in Initialization, we destroy it here
Options.Free;
end.