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

171 Visitors Online


 
...get the list of the installed softwares on a computer?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (8):  
     


uses
  
Registry;
  
procedure TForm1.Button1Click(Sender: TObject);
const
  
UNINST_PATH = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
var
  
Reg: TRegistry;
  SubKeys: TStringList;
  ListItem: TlistItem;
  i: integer;
  sDisplayName, sUninstallString: string;
begin
{
  ListView1.ViewStyle := vsReport;
  ListView1.Columns.add;
  ListView1.Columns.add;
  ListView1.Columns[0].caption := 'DisplayName';
  ListView1.Columns[1].caption := 'UninstallString';
  ListView1.Columns[0].Width := 300;
  ListView1.Columns[1].Width := 300;
}
  
Reg := TRegistry.Create;
  with Reg do
    try
      with 
ListView1.Items do
        try
          
BeginUpdate;
          Clear;
          RootKey := HKEY_LOCAL_MACHINE;
          if OpenKeyReadOnly(UNINST_PATH) then
          begin
            
SubKeys := TStringList.Create;
            try
              
GetKeyNames(SubKeys);
              CloseKey;
              for i := 0 to subKeys.Count - 1 do
                if 
OpenKeyReadOnly(Format('%s\%s', [UNINST_PATH, SubKeys[i]])) then
                  try
                    
sDisplayName     := ReadString('DisplayName');
                    sUninstallString := ReadString('UninstallString');
                    if sDisplayName <> '' then
                    begin
                      
ListItem         := Add;
                      ListItem.Caption := sDisplayName;
                      ListItem.subitems.Add(sUninstallString);
                    end;
                  finally
                    
CloseKey;
                  end;
            finally
              
SubKeys.Free;
            end;
          end;
        finally
          
ListView1.AlphaSort;
          EndUpdate;
        end;
    finally
      
CloseKey;
      Free;
    end;
end;


 

Rate this tip:

poor
very good


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