-
Notifications
You must be signed in to change notification settings - Fork 8
/
unit3.pas
74 lines (57 loc) · 1.51 KB
/
unit3.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
unit Unit3;
{$mode objfpc}{$H+}
interface
uses
Forms, StdCtrls;
const
VIDEODESKTOP_REG_KEY = 'VideoDesktop';
type
{ TForm3 }
TForm3 = class(TForm)
Button1: TButton;
Button2: TButton;
cbRunOnStartup: TCheckBox;
cbLoop: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.lfm}
uses
UFunctions, Registry;
{ TForm3 }
procedure TForm3.FormCreate(Sender: TObject);
begin
cbRunOnStartup.Checked := Config.ReadBool(GLOBAL_SECTION, RUNONSTARTUP_VALUE, True);
cbLoop.Checked := Config.ReadBool(GLOBAL_SECTION, LOOPVIDEOS_VALUE, True);
end;
procedure TForm3.Button1Click(Sender: TObject);
var
Reg: TRegistry;
begin
Config.WriteBool(GLOBAL_SECTION, RUNONSTARTUP_VALUE, cbRunOnStartup.Checked);
Config.WriteBool(GLOBAL_SECTION, LOOPVIDEOS_VALUE, cbLoop.Checked);
Reg := TRegistry.Create();
try
Reg.RootKey := HKEY_CURRENT_USER;
if (Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', False)) then
begin
if ((not Reg.ValueExists(VIDEODESKTOP_REG_KEY)) and (cbRunOnStartup.Checked)) then
Reg.WriteString(VIDEODESKTOP_REG_KEY, '"' + Application.ExeName + '"')
else if ((Reg.ValueExists(VIDEODESKTOP_REG_KEY)) and
(not cbRunOnStartup.Checked)) then
Reg.DeleteValue(VIDEODESKTOP_REG_KEY);
Reg.CloseKey();
end;
finally
Reg.Free();
end;
Self.Close();
end;
end.