61 lines
1.4 KiB
Plaintext
61 lines
1.4 KiB
Plaintext
unit DSetting;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
|
|
|
|
type
|
|
TDlgSetting = class(TForm)
|
|
chAutoRun: TCheckBox;
|
|
chAutoWatch: TCheckBox;
|
|
btnOk: TButton;
|
|
btnCancel: TButton;
|
|
procedure btnOkClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
Constructor Create(aOwner: TComponent); override;
|
|
end;
|
|
|
|
var
|
|
DlgSetting: TDlgSetting;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.IniFiles, Tocsg.Safe, Tocsg.Path, Tocsg.Registry;
|
|
|
|
{$R *.dfm}
|
|
|
|
Constructor TDlgSetting.Create(aOwner: TComponent);
|
|
var
|
|
ini: TIniFile;
|
|
begin
|
|
Inherited Create(aOwner);
|
|
|
|
Guard(ini, TIniFile.Create(CutFileExt(GetRunExePath) + '.ini'));
|
|
chAutoRun.Checked := ini.ReadBool('Setting', 'AutoRun', ExistsRunAppByHLM('FileToss', HKEY_CURRENT_USER));
|
|
chAutoWatch.Checked := ini.ReadBool('Setting', 'AutoWatch', false);
|
|
end;
|
|
|
|
procedure TDlgSetting.btnOkClick(Sender: TObject);
|
|
var
|
|
ini: TIniFile;
|
|
begin
|
|
Guard(ini, TIniFile.Create(CutFileExt(GetRunExePath) + '.ini'));
|
|
ini.WriteBool('Setting', 'AutoRun', chAutoRun.Checked);
|
|
ini.WriteBool('Setting', 'AutoWatch', chAutoWatch.Checked);
|
|
|
|
if chAutoRun.Checked then
|
|
AddRunAppByHLM('FileToss', GetRunExePath, HKEY_CURRENT_USER)
|
|
else
|
|
DeleteRunAppByHLM('FileToss', HKEY_CURRENT_USER);
|
|
|
|
ModalResult := mrOk;
|
|
end;
|
|
|
|
end.
|