Как осуществить следующее:
При нажатии на кнопку, надо вывести в список все зарегистрированные на компьютере ActiveX. Спасибо.
procedure ListTypeInfo(ClassID: TGUID; List: TStrings);
var
Obj: IDispatch;
TypeInfo: ITypeInfo;
TypeAttr: PTypeAttr;
iCnt: integer;
begin
Obj := CreateComObject(ClassID) as IDispatch;
Obj.GetTypeInfoCount(iCnt);
if iCnt > 0 then
begin
Obj.GetTypeInfo(0, 0, TypeInfo);
OleCheck(TypeInfo.GetTypeAttr(TypeAttr));
try
if (TypeAttr.typeKind in [TKIND_DISPATCH, TKIND_INTERFACE]) then
LoadInterface(TypeInfo, TypeAttr, List);
finally
TypeInfo.ReleaseTypeAttr(TypeAttr);
end;
end;
end;procedure LoadInterface(TypeInfo: ITypeInfo; TypeAttr: PTypeAttr; List:
TStrings);
var
AName: WideString;
ADocString: WideString;
AHelpContext: LongInt;
FuncDesc: PFuncDesc;
i, j: Integer;
Names: PBStrList;
cNames: Integer;
strItem: string;
begin
TypeInfo.GetDocumentation(-1, @AName, @ADocString, @AHelpContext, nil);
New(Names);
try
// load functions
for i := 0 to TypeAttr.cFuncs - 1 do
begin
TypeInfo.GetFuncDesc(i, FuncDesc);
try
TypeInfo.GetDocumentation(FuncDesc.memid, @AName, @ADocString,
@AHelpContext, nil);
strItem := AName;
if FuncDesc.cParams > 0 then
begin
// load parameters
TypeInfo.GetNames(FuncDesc.memid, Names, SizeOf(TBStrList),
cNames);
strItem := strItem + '(';
// Skip Names[0] - it's the function name
for j := 1 to FuncDesc.cParams do
if j < 2 then
strItem := strItem + Names[j]
else
strItem := strItem + ', ' + Names[j];
strItem := strItem + ')';
end;
if (ADocString <> '') then
strItem := strItem + #9 + ADocString;
list.Add(strItem);
finally
TypeInfo.ReleaseFuncDesc(FuncDesc);
end;
end;
finally
Dispose(Names);
end;
end;