uses Registry
var
reg : TRegistry;
//
procedure Scan;
var
s: string;
i,j: integer;
p: TStringList;
begin
Form1.ListBox1.Clear;
reg:=TRegistry.Create;
p:=TStringList.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall')
then
begin
reg.GetKeyNames(p);
reg.CloseKey;
end;
Form1.ListBox1.Items.Assign(p);
p.Free;
i:=0;
j:=Form1.ListBox1.Items.Count-1;
while i<=j do
begin
if reg.OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'
+Form1.ListBox1.Items.Strings[i])
then
begin
s:=reg.ReadString('UninstallString');
if s=''
then
begin
Form1.ListBox1.Items.Delete(i);
dec(j);
end
else inc(i);
end;
reg.CloseKey;
end;
reg.Free;
Form1.ListBox1.Selected[0]:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Scan;
ListBox1Click(Sender);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
reg:=TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'
+ListBox1.Items.Strings[ListBox1.ItemIndex],false)
then Edit1.Text:=reg.ReadString('UninstallString');
reg.CloseKey;
reg.Free;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.FormCreate(Sender);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
WinExec(PChar(Edit1.Text), SW_SHOW);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
reg:=TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
try
if reg.DeleteKey('SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/'
+ ListBox1.Items.Strings[ListBox1.ItemIndex])
then begin
Showmessage('Key deleted');
end else begin
Showmessage('No Key');
end;
finally
reg.Free;
end;
Scan;
ListBox1Click(Sender);
end;
Keine Kommentare:
Kommentar veröffentlichen