Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Querying the Audio Cd Autorun feature of Win32


How can I query the Audio Cd Autorun feature of Win32, and how can I set this value?   

    This setting is stored under the two following Windows registry keys: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AudioCD\Shell HKEY_CLASSES_ROOT\AudioCD\Shell The value will be the string "play" if the Autorun feature is enabled. The following example demonstrates both reading and writing these key values. Example:

    function IsAudioCdAutoRunOn : bool;
    var
      reg: TRegistry;
      Classes : string;
      ClassesRoot : string;
      i : integer;
    begin
      reg := TRegistry.Create;
      reg.RootKey := HKEY_LOCAL_MACHINE;
      reg.OpenKey('SOFTWARE\Classes\AudioCD\Shell',
                  false);
      Classes := reg.ReadString('');
      reg.CloseKey;
      reg.RootKey := HKEY_CLASSES_ROOT;
      reg.OpenKey('AudioCD\Shell',
                  false);
      ClassesRoot := reg.ReadString('');
      reg.CloseKey;
      reg.free;
      for i :=   to length(Classes) do
        Classes[i] := UpCase(Classes[i]);
      for i :=   to length(ClassesRoot) do
        ClassesRoot[i] := UpCase(ClassesRoot[i]);
      result := ((Classes = 'PLAY') and
                 (ClassesRoot = 'PLAY'));
    end;
    procedure SetAudioCdAutoRun(bOn : bool);
    var
      reg: TRegistry;
      Classes : string;
      ClassesRoot : string;
    begin
      reg := TRegistry.Create;
      reg.RootKey := HKEY_LOCAL_MACHINE;
      reg.OpenKey('SOFTWARE\Classes\AudioCD\Shell',
                  false);
      if bOn then
        reg.WriteString('', 'play') else
        reg.WriteString('', '');
      reg.CloseKey;
      reg.RootKey := HKEY_CLASSES_ROOT;
      reg.OpenKey('AudioCD\Shell',
                  false);
      if bOn then
        reg.WriteString('', 'play') else
        reg.WriteString('', '');
      reg.CloseKey;
      reg.free;
    end;
    procedure TForm .Button Click(Sender: TObject);
    begin
      if IsAudioCdAutoRunOn then
        ShowMessage('Autorun Audio Cd is On') else
        ShowMessage('Autorun Audio Cd is Off');
    end;
    procedure TForm .Button2Click(Sender: TObject);
    begin
      SetAudioCdAutoRun(true);
    end;
    procedure TForm .Button3Click(Sender: TObject);
    begin
      SetAudioCdAutoRun(false);
    end;
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use