转贴,获得系统程序安装列表

{

Author: Cosmin Pîrlitu
E-mail: [email protected]

The following code uses one ListBox (lbApps) and one button (btnGetApps) placed on the form (frmMain).

When the user clicks on the "Get App List" button the program extracts the list of all the installed apps from the Registry and adds *only* the valid ones to the ListBox.

I appologise for eventual spelling errors...

}

uses Registry;

{...code...}

const BaseKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';

{...code...}

procedure TfrmMain.btnGetAppsClick(Sender: TObject);
var Reg: TRegistry;
Entries, i: integer;
vList: TStringList;
begin
lbApps.Clear;
Reg:=TRegistry.Create;
vList:=TStringList.Create;
with Reg do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey(BaseKey, False);

GetKeyNames(vList);
Entries:=vList.Count;

for i:=0 to Entries-1 do
begin
CloseKey;
OpenKey(BaseKey+'\'+vList.Strings[i],false);
if ValueExists('DisplayName') then
lbApps.Items.Add(ReadString('DisplayName'))
end;
end;

{ cleanup after job is done }
Reg.Free;
vList.Free;
end;
原文连接

你可能感兴趣的:(windows,Microsoft,asp)