1 2 /*3 The installed software information is stored in the Registry.4 5 Installed on All Users6 Rootkey : HKEY_LOCAL_MACHINE7 Path : SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall8 9 Installed on Current User10 Rootkey : HKEY_CURRENT_USER11 Path : SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall12 13 DisplayName is the title of the program.14 UnistallString is the path used for uninstallation of the software.15 If DisplayName and UnistallString exists it is a installet program.16 */17 18 //This example shows how to get the installed software for all users.19 //---------------------------------------------------------------------------20 21 #include <vcl.h>
22 #include <Registry.hpp>
23 #pragma hdrstop
24 25 #include "Unit1.h"
26 //---------------------------------------------------------------------------27 #pragma package(smart_init)
28 #pragma resource "*.dfm"
29 TForm1 *Form1;
30 //---------------------------------------------------------------------------31 __fastcall TForm1::TForm1(TComponent* Owner)
32 : TForm(Owner)
33 {
34 }
35 //---------------------------------------------------------------------------36 37 void__fastcall TForm1::Button1Click(TObject *Sender)
38 {
39 TStringList *Keys = new TStringList();
40 TRegistry *Reg = new TRegistry();
41 42 // Change the rootkey to HKEY_CURRENT_USER to get the installed software for the 43 current user.
44 Reg->RootKey = HKEY_LOCAL_MACHINE ;
45 Reg->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", false);
46 Reg->GetKeyNames(Keys);
47 Reg->CloseKey();
48 for(int i=0;i<Keys->Count;i++){
49 if (Reg->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+
50 Keys->Strings[i], false)) {
51 if(Reg->ValueExists("DisplayName") == Reg->ValueExists("UninstallString")){
52 ListBox1->Items->Add(Reg->ReadString("DisplayName")+" |
53 "Reg->ReadString("UninstallString"));
54 Reg->CloseKey();
55 }
56 }
57 }
58 Reg->Free();
59 Keys->Free();
60 61 }
62 //---------------------------------------------------------------------------63