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
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
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;
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;
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;