1

Possible Duplicate:
How to list all installed ActiveX controls?

I want to get a full list of available activeX controls on user system. Just like what delphi does when you want to import an activeX. (it shows a list)

Regards, Javid

Community
  • 1
  • 1
Javid
  • 2,755
  • 2
  • 33
  • 60
  • 1
    duplicate of http://stackoverflow.com/questions/1649171/how-to-list-all-activex-controls ? – RBA Mar 07 '11 at 08:19
  • I want to do this using Delphi. I want to do it with coding, not by external stuff. – Javid Mar 07 '11 at 09:07
  • It does appear to be a dupe, but of a different [question](http://stackoverflow.com/questions/2755351/). On the plus side, this does answer your question! – David Heffernan Mar 07 '11 at 10:01

3 Answers3

1

Here is a c++ version of what you want (almost). You get a list of all classes. It guess that the ActiveX import wizard in Delphi has one row for each library. How to list all installed ActiveX controls?

In Delphi you can do something like this.

const
    CATID_Control: TGUID  = '{40FC6ED4-2438-11cf-A3DB-080036F12502}';

procedure GetActiveXControlList(List: TStringList);
var
    catInfo: ICatInformation;
    enumGuid: IEnumGUID;
    ClassID: TGUID;
    Fetched: Cardinal;
    Name: PWideChar;
begin
    OleCheck(CoCreateInstance(CLSID_StdComponentCategoryMgr, nil,
            CLSCTX_INPROC_SERVER, ICatInformation, CatInfo));

    catInfo.EnumClassesOfCategories(1, @CATID_Control, 0, @GUID_NULL, EnumGUID);
    while enumGuid.Next(1, ClassID, Fetched) = S_OK do
    begin
        OleCheck(OleRegGetUserType(ClassID, USERCLASSTYPE_FULL, Name));
        List.Add(Name);
    end;
end;
Community
  • 1
  • 1
Mikael Eriksson
  • 136,425
  • 22
  • 210
  • 281
1

This is pretty much a direct port of the PowerShell solution from Jeff Atwood:

procedure GetActiveXObjects( strings : TStrings );
const
    BASE_KEY = '\Software\Classes';
var
    reg : TRegistry;
    keys : TStrings;
    regex : TPerlRegEx;
    key : String;
begin
strings.Clear;
keys := nil;
regex := nil;
reg := TRegistry.Create;
try
    reg.RootKey := HKEY_LOCAL_MACHINE;
    reg.OpenKeyReadOnly( BASE_KEY );

    keys := TStringList.Create;
    reg.GetKeyNames( keys );

    regex := TPerlRegEx.Create;
    regex.RegEx := '^\w+\.\w+$';

    for key in keys do
        begin
        regex.Subject := key;
        if regex.Match and reg.KeyExists( BASE_KEY + '\' + key + '\CLSID' ) then
            strings.Add( key )
        end;

finally
    reg.Free;
    keys.Free;
    regex.Free;
    end;
end;
Community
  • 1
  • 1
Alistair Ward
  • 1,093
  • 9
  • 20
0

This is what I wrote myself. Just add Registry unit and you're finished!

procedure GetActiveXObjects(List: TStringList);
  procedure KeyNotFound;
  begin
    raise exception.create('Key not found.');
  end;
const
  PATH = 'Software\\Classes\\TypeLib\\';
var
  R: TRegistry;
  S1, S2: TStringList;
  S, Output: String;
begin
  List.Clear;
  try
    S1 := TStringList.Create;
    S2 := TStringList.Create;
    R := TRegistry.create(KEY_READ);
    R.RootKey := HKEY_LOCAL_MACHINE;

    if (not R.OpenKey(PATH, False)) then
      KeyNotFound;
    R.GetKeyNames(S1);
    for S in S1 do begin
      // Position: CLSID
      R.CloseKey;
      if (not R.OpenKeyReadOnly(PATH + S + '\\')) then
        Continue;
      R.GetKeyNames(S2);
      // Position:Version
      if (S2.Text = '') or (not R.OpenKeyReadOnly(S2.Strings[0])) then
        Continue;
      Output := R.ReadString('');
      if Output <> '' then
        List.Add(Output);
    end;

  finally
    R.Free;
    S1.Free;
    S2.Free;
  end;
end;
Javid
  • 2,755
  • 2
  • 33
  • 60