Code
uses registry;
procedure TForm1.Button1Click(Sender: TObject);
const CLAVE =
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'; //定义读取常量
var
reg : TRegistry; //定义要使用到的变量
Lista : TStringList;
Lista2 : TStringList;
i,n : integer;
Newlist : Tlistitem;
begin
listview1.Clear;
reg := TRegistry.Create; //派生新的实例
Lista := TStringList.Create; //Create all new example
Lista2 := TStringList.Create;
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey(CLAVE,false);
GetKeyNames(Lista); //load all the subkeys
end;
for i := 0 to Lista.Count -1 do // load all the Value Names
begin
reg.OpenKey(CLAVE + '\' +Lista.Strings,false);
reg.GetValueNames(Lista2);
n:=Lista2.IndexOf('DisplayName'); //We will show only if there is 'DisplayName'
if (n <> -1) and (Lista2.IndexOf('UninstallString')<>-1) then
begin
{Output the values to listview1 ->DisplayName+UnInstallString}
Newlist:= ListView1.Items.Add;
Newlist.Caption:= reg.ReadString(Lista2.Strings[n]);
Newlist.SubItems.Add(reg.ReadString(Lista2.Strings[Lista2.IndexOf('UninstallString')]));
end;
end;
Lista.Free; //free all useage example
Lista2.Free;
reg.CloseKey;
reg.Destroy; //==shource code end===
end;
uses registry;
procedure TForm1.Button1Click(Sender: TObject);
const CLAVE =
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'; //定义读取常量
var
reg : TRegistry; //定义要使用到的变量
Lista : TStringList;
Lista2 : TStringList;
i,n : integer;
Newlist : Tlistitem;
begin
listview1.Clear;
reg := TRegistry.Create; //派生新的实例
Lista := TStringList.Create; //Create all new example
Lista2 := TStringList.Create;
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey(CLAVE,false);
GetKeyNames(Lista); //load all the subkeys
end;
for i := 0 to Lista.Count -1 do // load all the Value Names
begin
reg.OpenKey(CLAVE + '\' +Lista.Strings,false);
reg.GetValueNames(Lista2);
n:=Lista2.IndexOf('DisplayName'); //We will show only if there is 'DisplayName'
if (n <> -1) and (Lista2.IndexOf('UninstallString')<>-1) then
begin
{Output the values to listview1 ->DisplayName+UnInstallString}
Newlist:= ListView1.Items.Add;
Newlist.Caption:= reg.ReadString(Lista2.Strings[n]);
Newlist.SubItems.Add(reg.ReadString(Lista2.Strings[Lista2.IndexOf('UninstallString')]));
end;
end;
Lista.Free; //free all useage example
Lista2.Free;
reg.CloseKey;
reg.Destroy; //==shource code end===
end;