-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProperties.pas
104 lines (85 loc) · 3.07 KB
/
Properties.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
unit Properties;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, JvComponentBase, JvXPCore, JclRegistry, ShellAPI;
type
TfrmProperties = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
Bevel4: TBevel;
Label1: TLabel;
Label2: TLabel;
cbBalloonNotification: TCheckBox;
cbSoundNotification: TCheckBox;
btnConfigureSound: TButton;
cbAutostart: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
cbUseTestBackend: TCheckBox;
procedure btnCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnConfigureSoundClick(Sender: TObject);
procedure cbSoundNotificationClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
const
strRegPathRun = '\Software\Microsoft\Windows\CurrentVersion\Run';
strRegPathApp = '\Software\Jens Bretschneider\';
var
frmProperties: TfrmProperties;
implementation
{$R *.dfm}
procedure TfrmProperties.btnCancelClick(Sender: TObject);
begin
frmProperties.Close;
end;
procedure TfrmProperties.FormShow(Sender: TObject);
var
s: string;
begin
s := RegReadStringDef(HKEY_CURRENT_USER, strRegPathRun, Application.Title, '');
cbAutostart.Checked := (s = Application.ExeName);
cbBalloonNotification.Checked := RegReadBoolDef(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'BalloonNotification', true);
cbSoundNotification.Checked := RegReadBoolDef(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'SoundNotification', true);
cbUseTestBackend.Checked := RegReadBoolDef(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'UseTestBackend', false);
cbUseTestBackend.Visible := (GetAsyncKeyState(VK_SHIFT) and $8000 <> 0);
cbSoundNotification.OnClick(self);
end;
procedure TfrmProperties.btnConfigureSoundClick(Sender: TObject);
begin
ShellExecute(0, 'OPEN', PChar('control.exe'), PChar('mmsys.cpl sounds'), '', SW_SHOWNORMAL);
end;
procedure TfrmProperties.cbSoundNotificationClick(Sender: TObject);
begin
btnConfigureSound.Enabled := cbSoundNotification.Checked;
end;
procedure TfrmProperties.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if ModalResult = mrOK then begin
if cbAutostart.Checked then begin
RegWriteString(HKEY_CURRENT_USER, strRegPathRun, Application.Title, Application.ExeName);
end else begin
try
RegDeleteEntry(HKEY_CURRENT_USER, strRegPathRun, Application.Title)
except
end;
end;
RegWriteBool(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'BalloonNotification', cbBalloonNotification.Checked);
RegWriteBool(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'SoundNotification', cbSoundNotification.Checked);
RegWriteBool(HKEY_CURRENT_USER, strRegPathApp + Application.Title,
'UseTestBackend', cbUseTestBackend.Checked);
end;
end;
end.