H
hami
Unregistered / Unconfirmed
GUEST, unregistred user!
function IsCdAutoRunOn:bool;
var
reg:TRegistry;
AutoRunSetting : integer;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey(
'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',
false);
AutoRunSetting:=reg.ReadInteger('NoDriveTypeAutoRun');
reg.CloseKey;
reg.free;
result := not ((AutoRunSetting and (1 shl 5)) <> 0);
end;
procedure SetCdAutoRun(bOn : bool);
var
reg: TRegistry;
AutoRunSetting : integer;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.LazyWrite := false;
reg.OpenKey(
'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',
false);
AutoRunSetting:=reg.ReadInteger('NoDriveTypeAutoRun');
if bOn then
AutoRunSetting := AutoRunSetting and not (1 shl 5)
else
AutoRunSetting := AutoRunSetting or (1 shl 5);
reg.WriteInteger('NoDriveTypeAutoRun',AutoRunSetting);
reg.CloseKey;
reg.free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsCdAutoRunOn then
RadioGroup1.ItemIndex:=0
else
RadioGroup1.ItemIndex:=1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex=0 then
SetCdAutoRun(True)
else
SetCdAutoRun(False);
end;
var
reg:TRegistry;
AutoRunSetting : integer;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey(
'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',
false);
AutoRunSetting:=reg.ReadInteger('NoDriveTypeAutoRun');
reg.CloseKey;
reg.free;
result := not ((AutoRunSetting and (1 shl 5)) <> 0);
end;
procedure SetCdAutoRun(bOn : bool);
var
reg: TRegistry;
AutoRunSetting : integer;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.LazyWrite := false;
reg.OpenKey(
'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',
false);
AutoRunSetting:=reg.ReadInteger('NoDriveTypeAutoRun');
if bOn then
AutoRunSetting := AutoRunSetting and not (1 shl 5)
else
AutoRunSetting := AutoRunSetting or (1 shl 5);
reg.WriteInteger('NoDriveTypeAutoRun',AutoRunSetting);
reg.CloseKey;
reg.free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsCdAutoRunOn then
RadioGroup1.ItemIndex:=0
else
RadioGroup1.ItemIndex:=1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex=0 then
SetCdAutoRun(True)
else
SetCdAutoRun(False);
end;