Author: Mike Heydon
Answer:
This procedure enables you to browse a list of Registered GUID classes from
HKEY_LOCAL_MACHINE\Software\Classes\CLSID. The object name is the name as used by
the Delphi function "CreateOleObject('Outlook.Application')" etc. The procedure
sets a TStrings object (eg. TListBox.Items or TMemo.Lines) to the Description of
the GUID (if any), the Separator (Default is "@") and the OLE object name (eg.
Outlook.Application.9).
There are numerous objects in this portion of the registry, I was only interested
in entries that had a "ProgID" key within. Another key of interest is
"VersionIndependantProgID" which exists for certain entries. eg. Microsft Outlook
has for instance ..
ProgID = Outlook.Application.9
VersionIndependantProgID = Outlook.Application
You may wish to return the version independant key instead of the actual key (up to
you).
An example of use could be ....
LoadCLSID(ListBox1.Items);
ListBox1.Sorted := true;
The output looks something like
...
...
Microsoft OLE DB Service Component Data Links@DataLinks
Microsoft Organization Extension@MSExtOrganization
Microsoft OrganizationUnit Extension@MSExtOrganizationUnit
Microsoft Outlook@Outlook.Application.9
Microsoft Photo Editor 3.0 Photo@MSPhotoEd.3
Microsoft Photo Editor 3.0 Scan@MSPhotoEdScan.3
Microsoft Powerpoint Application@PowerPoint.Application.9
Microsoft PowerPoint Presentation@PowerPoint.Show.8
Microsoft PowerPoint Slide@PowerPoint.Slide.8
Microsoft PptNsRex Control@PptNsRex.PptNsRex.1
Microsoft PrintQueue Extension@MSExtPrintQueue
Microsoft Repository Class Definition@ReposClassDef.0
etc
...
...
The listing contains many interesting and unexplored possibilities.
Happy Hunting.
1 uses Registry;
2 3 procedure LoadCLSID(StringList: TStrings; Separator: char = '@');
4 const5 REGKEY = 'Software\Classes\CLSID';
6 var7 WinReg: TRegistry;
8 KeyNames, SubKeyNames: TStringList;
9 i: integer;
10 KeyDesc: string;
11 begin12 StringList.Clear;
13 KeyNames := TStringList.Create;
14 SubKeyNames := TStringList.Create;
15 WinReg := TRegistry.Create;
16 WinReg.RootKey := HKEY_LOCAL_MACHINE;
17 18 if WinReg.OpenKey(REGKEY, false) then19 begin20 WinReg.GetKeyNames(KeyNames);
21 WinReg.CloseKey;
22 23 // Traverse list of GUID numbers eg. {00000106-0000-0010-8000-00AA006D2EA4}24 for i := 1 to KeyNames.Count - 1 do25 begin26 // Check if key "ProgID" exists in open key ?27 if WinReg.OpenKey(REGKEY + '\' + KeyNames[i], false) then28 begin29 if WinReg.KeyExists('ProgID') then30 begin31 KeyDesc := WinReg.ReadString(''); // Read (Default) value32 WinReg.CloseKey;
33 34 if WinReg.OpenKey(REGKEY + '\' + KeyNames[i] +
35 '\ProgID', false) then36 begin37 // Add description of GUID and OLE object name to passed list38 StringList.Add(KeyDesc + Separator + WinReg.ReadString(''));
39 WinReg.CloseKey;
40 end;
41 end42 else43 WinReg.CloseKey;
44 end;
45 end;
46 end;
47 48 WinReg.Free;
49 SubKeyNames.Free;
50 KeyNames.Free;
51 end;