首页  编辑  

光盘的自动运行

Tags: /超级猛料/Hardware.硬件相关/驱动器相关/光驱/   Date Created:

设置光盘的自动运行特征:

procedure TForm1.SetCDAutoRun(AAutoRun:Boolean);

const

 DoAutoRun : array[Boolean] of Integer = (0,1);

var

 Reg : TRegistry;

begin

 try

   { create our registry object }

   Reg := TRegistry.Create;

   { set our registry root key }

   Reg.RootKey := HKEY_LOCAL_MACHINE;

   { verify that our CDROM class key exists }

   if Reg.KeyExists('System\CurrentControlSet\Services\Class\CDROM') then

     { try to open our CDROM class key }

     if Reg.OpenKey('System\CurrentControlSet\Services\Class\CDROM',FALSE) then

       { add AutoRun to our CDROM class key }

       Reg.WriteBinaryData('AutoRun',DoAutoRun[AAutoRun],1);

 finally

   { free our registry object }

   Reg.Free;

 end;

 { showmessage that the changes will happen on reboot }

 ShowMessage('Your settings will take effect on the next reboot of Windows.');

end;