Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
COM/OLE Object Name Utility Procedure Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
22-Oct-02
Category
COM+
Language
Delphi 5.x
Views
122
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   const
5     REGKEY = 'Software\Classes\CLSID';
6   var
7     WinReg: TRegistry;
8     KeyNames, SubKeyNames: TStringList;
9     i: integer;
10    KeyDesc: string;
11  begin
12    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) then
19    begin
20      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 do
25      begin
26        // Check if key "ProgID" exists in open key ?
27        if WinReg.OpenKey(REGKEY + '\' + KeyNames[i], false) then
28        begin
29          if WinReg.KeyExists('ProgID') then
30          begin
31            KeyDesc := WinReg.ReadString(''); // Read (Default) value
32            WinReg.CloseKey;
33  
34            if WinReg.OpenKey(REGKEY + '\' + KeyNames[i] +
35              '\ProgID', false) then
36            begin
37              // Add description of GUID and OLE object name to passed list
38              StringList.Add(KeyDesc + Separator + WinReg.ReadString(''));
39              WinReg.CloseKey;
40            end;
41          end
42          else
43            WinReg.CloseKey;
44        end;
45      end;
46    end;
47  
48    WinReg.Free;
49    SubKeyNames.Free;
50    KeyNames.Free;
51  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC