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
How to get a list of all registered typelibs 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
17-Oct-02
Category
Win API
Language
Delphi 2.x
Views
48
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Jonas Bilinkevicius

Does anybody know how to get a list of all registered typelibs (like the list in 
the typelib import window in Delphi)? I found a place in the registry 
(HKCR\TypeLib\...) but a lot of libs are listed more then one time (up to 4 or 5 
times) in that place. Do I have to grab all libs from this place? I have found no 
API (like EnumTypeLibs) that does this.

Answer:

1   procedure EnumTypeLibs(TypeLibNames: TStringList);
2   var
3     f: TRegistry;
4     keyNames, keyVersions, keyInfos: TStringList;
5     keyName, keyVersion, keyInfo, tlName: string;
6     i, j, k: Integer;
7   begin
8     TypeLibNames.Clear;
9     {TypeLibNames.Sorted := True;}
10    keyNames := nil;
11    keyVersions := nil;
12    keyInfos := nil;
13    f := TRegistry.Create;
14    try
15      keyNames := TStringList.Create;
16      keyVersions := TStringList.Create;
17      keyInfos := TStringList.Create;
18      f.RootKey := HKEY_CLASSES_ROOT;
19      if not f.OpenKey('TypeLib', False) then
20        raise Exception.Create('TRegistry.Open');
21      f.GetKeyNames(keyNames);
22      f.CloseKey;
23      for i := 0 to keyNames.Count - 1 do
24      begin
25        keyName := keyNames.Strings[i];
26        if not f.OpenKey(Format('TypeLib\%s', [keyName]), False) then
27          Continue;
28        f.GetKeyNames(keyVersions);
29        f.CloseKey;
30        for j := 0 to keyVersions.Count - 1 do
31        begin
32          keyVersion := keyVersions.Strings[j];
33          if not f.OpenKey(Format('TypeLib\%s\%s', [keyName, keyVersion]), False) then
34            Continue;
35          tlName := f.ReadString('');
36          f.GetKeyNames(keyInfos);
37          f.CloseKey;
38          for k := 0 to keyInfos.Count - 1 do
39          begin
40            keyInfo := keyInfos.Strings[k];
41   {$B-}
42            if (keyInfo = '') or (keyInfo[1] < '0') or (keyInfo[1] > '9') then
43              Continue;
44            if not f.OpenKey(Format('TypeLib\%s\%s\%s\win32', [keyName, keyVersion,
45              keyInfo]), False) then
46              Continue;
47            f.CloseKey;
48            TypeLibNames.Add(Format('%s ver.%s', [tlName, keyVersion]));
49          end;
50        end;
51      end;
52    finally
53      f.Free;
54      keyNames.Free;
55      keyVersions.Free;
56      keyInfos.Free;
57    end;
58  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