2010. július 19., hétfő
COM/OLE Object Name Utility Procedure
Problem/Question/Abstract:
COM/OLE Object Name Utility Procedure
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.
uses Registry;
procedure LoadCLSID(StringList: TStrings; Separator: char = '@');
const
REGKEY = 'Software\Classes\CLSID';
var
WinReg: TRegistry;
KeyNames, SubKeyNames: TStringList;
i: integer;
KeyDesc: string;
begin
StringList.Clear;
KeyNames := TStringList.Create;
SubKeyNames := TStringList.Create;
WinReg := TRegistry.Create;
WinReg.RootKey := HKEY_LOCAL_MACHINE;
if WinReg.OpenKey(REGKEY, false) then
begin
WinReg.GetKeyNames(KeyNames);
WinReg.CloseKey;
// Traverse list of GUID numbers eg. {00000106-0000-0010-8000-00AA006D2EA4}
for i := 1 to KeyNames.Count - 1 do
begin
// Check if key "ProgID" exists in open key ?
if WinReg.OpenKey(REGKEY + '\' + KeyNames[i], false) then
begin
if WinReg.KeyExists('ProgID') then
begin
KeyDesc := WinReg.ReadString(''); // Read (Default) value
WinReg.CloseKey;
if WinReg.OpenKey(REGKEY + '\' + KeyNames[i] +
'\ProgID', false) then
begin
// Add description of GUID and OLE object name to passed list
StringList.Add(KeyDesc + Separator + WinReg.ReadString(''));
WinReg.CloseKey;
end;
end
else
WinReg.CloseKey;
end;
end;
end;
WinReg.Free;
SubKeyNames.Free;
KeyNames.Free;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése