以下提供範例函式, 呼叫LoadLibProgID可以列舉出Dll中的CoClass的ProgID及GUID,
不要忘了在Use中加入ComObj及ActiveX
function GetTypeNameGUID(ITypeUse: ITypeInfo; var NameGUID: string): boolean;
var
uAttr: PTypeAttr;
sCoClass: WideString;
begin
with ITypeUse do
begin
OleCheck(GetTypeAttr(uAttr));
try
if ((uAttr^.wTypeFlags and TYPEFLAG_FHIDDEN) = 0) and
(uAttr^.cImplTypes > 0) then
begin
OleCheck(GetDocumentation(-1, @sCoClass, nil, nil, nil));
NameGUID := sCoClass + '/' + GUIDToString(uAttr^.guid);
Result := True;
end else
Result := False;
finally
ReleaseTypeAttr(uAttr);
end;
end;
end;
function LoadLibProgID(const FileName: string; ProgID: TStrings; RaiseError: boolean): boolean;
var
ITypeUse: ITypeLib;
swFile: WideString;
lRet: HResult;
begin
Result := False;
ProgID.BeginUpdate;
try
ProgID.Clear;
swFile := WideString(FileName);
lRet := LoadTypeLib(@swFile[1], ITypeUse);
if lRet = S_OK then begin
GetLibProgID(ITypeUse, ProgID);
Result := True;
end else
if RaiseError then OleCheck(lRet);
finally
ProgID.EndUpdate;
end;
end;
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1058202
Delphi中如何能够动态地获取一个类的方法列表,并动态地访问该类的方法? (100分)