delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


COM/OLE Object Name Utility ProcedureFormat this article printer-friendly!Bookmark function is only available for registered users!
LoadCLSID()
Product:
Delphi 4.x (or higher)
Category:
OLE
Skill Level:
Scoring:
Last Update:
04/03/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet OLE "Object Name" CLASS CLSID
Times Scored:
2
Visits:
5288
Uploader: Mike Heydon
Company: EOH
Reference: mheydon@eoh.co.za
 
Question/Problem/Abstract:
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.
Answer:



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;






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
C.A. Longen
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)