home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d56 / MSYSINFO.ZIP / Source / MSI_Software.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-07-24  |  2.0 KB  |  87 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       MiTeC System Information Component              }
  5. {         Installed Software Detection Part             }
  6. {           version 6.0 for Delphi 5,6                  }
  7. {                                                       }
  8. {       Copyright ⌐ 1997,2001 Michal Mutl               }
  9. {                                                       }
  10. {*******************************************************}
  11.  
  12. {$INCLUDE MITEC_DEF.INC}
  13.  
  14. unit MSI_Software;
  15.  
  16. interface
  17.  
  18. uses
  19.   SysUtils, Windows, Classes;
  20.  
  21. type
  22.   TSoftware = class(TPersistent)
  23.   private
  24.     FProducts: TStrings;
  25.   public
  26.     constructor Create;
  27.     destructor Destroy; override;
  28.     procedure GetInfo;
  29.     procedure Report(var sl :TStringList);
  30.   published
  31.     property Installed: TStrings read FProducts {$IFNDEF D6PLUS} write FProducts {$ENDIF} stored false;
  32.   end;
  33.  
  34. implementation
  35.  
  36. uses Registry, MiTeC_Routines;
  37.  
  38. { TSoftware }
  39.  
  40. constructor TSoftware.Create;
  41. begin
  42.   FProducts:=TStringList.Create;
  43. end;
  44.  
  45. destructor TSoftware.Destroy;
  46. begin
  47.   FProducts.Free;
  48.   inherited;
  49. end;
  50.  
  51. procedure TSoftware.GetInfo;
  52. const
  53.   rk = {HKEY_LOCAL_MACHINE\}'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
  54.   rv = 'DisplayName';
  55. var
  56.   i: integer;
  57.   sl: TStringList;
  58. begin
  59.   FProducts.Clear;
  60.   with TRegistry.Create do
  61.     try
  62.       RootKey:=HKEY_LOCAL_MACHINE;
  63.       if OpenKey(rk,False) then begin
  64.         sl:=TStringList.Create;
  65.         GetKeyNames(sl);
  66.         CloseKey;
  67.         for i:=0 to sl.Count-1 do
  68.           if OpenKey(rk+'\'+sl[i],False) then begin
  69.             if ValueExists(rv) then
  70.               FProducts.Add(ReadString(rv));
  71.             CloseKey;
  72.           end;
  73.         sl.Free;
  74.       end;
  75.     finally
  76.       Free;
  77.     end;
  78. end;
  79.  
  80. procedure TSoftware.Report(var sl: TStringList);
  81. begin
  82.   sl.Add('[Installed Software]');
  83.   StringsToRep(Installed,'Count','Item',sl);
  84. end;
  85.  
  86. end.
  87.