unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Registry, StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
btnApply: TButton;
procedure btnApplyClick(Sender: TObject);
private
{ Private declarations }
R : TRegistry;
ProxySetting : Integer;
public
{ Public declarations }
constructor Create(AOwner : TComponent);override;
end;
var
Form1: TForm1;
const
//The registry key where the setting is stored.
PROXY_KEY = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings';
implementation
{$R *.dfm}
{------------------------------------------------------------------------------}
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
R := TRegistry.Create;
try
R.RootKey := HKEY_CURRENT_USER;
if R.OpenKey(PROXY_KEY,False) then
begin
//Reading the state of the setting.
ProxySetting := R.ReadInteger('ProxyEnable');
case ProxySetting of
0: CheckBox1.Checked := False;
1: CheckBox1.Checked := True;
end;
end;
finally
R.CloseKey;
FreeAndNil(R);
end;
end;
{------------------------------------------------------------------------------}
procedure TForm1.btnApplyClick(Sender: TObject);
begin
{ TODO -oUser -cConsole Main : Insert code here }
R := TRegistry.Create;
try
R.RootKey := HKEY_CURRENT_USER;
if R.OpenKey(PROXY_KEY,False) then
begin
//Setting Proxy enable / disable.
ProxySetting := R.ReadInteger('ProxyEnable');
if CheckBox1.Checked then
R.WriteInteger('ProxyEnable',1)
else
R.WriteInteger('ProxyEnable',0);
end;
finally
R.CloseKey;
FreeAndNil(R);
end;
end;
{------------------------------------------------------------------------------}
end.