Activate/Deactivate the audio cd AutoPlay  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 16/09/99

Tip accessed 447 times

 


We eill make it, changint the value of the registry key:


 HKEY_LOCAL_MACHINE\Software\Classes\AudioCD\Shell\



Add 'Registry' in the uses of your form


 procedure TForm1.Button1Click(Sender: TObject);

   procedure CDAutoPlay(SioNo:Boolean);
   const
     DoPlay : array[Boolean] of String = ('','play');
   var
     Registro:TRegistry;
   begin
     try
       Registro := TRegistry.Create;
       {Fijamos raiz}
       {Set Root}
       Registro.RootKey := HKEY_LOCAL_MACHINE;
       {Verificamos que hay un cd audio}
       {Verify if audiocd exists}
       if Registro.KeyExists('Software\Classes\AudioCD\') then
         {Abrimos la clave audiocd}
         {Ppen the audiocd key }
         if Registro.OpenKey('Software\Classes\AudioCD\Shell\',FALSE) then
           {Cambiamos su valor}
           {Change their value}
           if SioNo then Registro.WriteString('','play')
                    else Registro.WriteString('','');
     finally
       {Liberamos Registro}
       {free Registro}
       Registro.Free;
     end;
   end;

 begin
   {Desconectar el AutoPlay:}
   {Deactivate the Autoplay:}
   CDAutoPlay(FALSE);

   {Activar el AutoPlay:}
   {Activate the AutoPlay:}
   CDAutoPlay(TRUE);
 end;