whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
...Enumerate all extensions and their servers in the registry?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (3):  
     


{
 This Code will return the programs associated with each extension.
 You can obviously modify it to search for a specific extension.
}

uses Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  
reg: TRegistry;
  keys: TStringList;
  i: Integer;
  typename, displayname, server: string;
begin
  
memo1.Clear;
  reg := TRegistry.Create;
  try
    
reg.rootkey := HKEY_CLASSES_ROOT;
    if reg.OpenKey('', False) then
    begin
      
keys := TStringList.Create;
      try
        
reg.GetKeyNames(keys);
        reg.CloseKey;
        {memo1.lines.addstrings(keys);}
        
for i := 0 to keys.Count - 1 do
        begin
          if 
keys[i][1] = '.' then
          begin
            
{this is an extension, get its typename}
            
if reg.OpenKey(keys[i], False) then
            begin
              
typename := reg.ReadString('');
              reg.CloseKey;
              if typename <> '' then
              begin
                if 
reg.OpenKey(typename, False) then
                begin
                  
displayname := reg.ReadString('');
                  reg.CloseKey;
                end;
                if reg.OpenKey(typename + '\shell\open\command', False) then
                begin
                  
server := reg.ReadString('');
                  memo1.Lines.Add(Format('Extension: "%s", Typename: "%s", Displayname:"%s"' +
                                         #13#10'  Server: %s',
                                         [keys[i], typename, displayname, server]));
                  reg.CloseKey;
                end;
              end;
            end;
          end;
        end;
      finally
        
keys.Free;
      end;
    end;
  finally
    
reg.Free
  end;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners