请问如何动态获取BPL中所有组件的信息?(200分)

  • 主题发起人 主题发起人 Ginger
  • 开始时间 开始时间
G

Ginger

Unregistered / Unconfirmed
GUEST, unregistred user!
LoadPackage以后,我怎样知道这个包中有哪些类呢?
 
TPackageInfoProc is a pointer to a callback procedure used as a parameter type to the GetPackageInfo procedure.

Unit

SysUtils

type

TNameType = (ntContainsUnit, ntRequiresPackage, ntDcpBpiName);

TPackageInfoProc = procedure (const Name: string; NameType: TNameType; Flags: Byte; Param: Pointer);

Description

TPackageInfoProc is the type of the callback passed to GetPackageInfo, which calls it once for each information element returned.

Name is the name of a package or package file. The precise meaning of the Name parameter depends on the value of the NameType parameter.

NameType is one of the following values:

Value Meaning

ntContainsUnit The Name parameter is the name of a unit contained in the package.
ntRequiresPackage The Name parameter is the name of another package required by the package.
ntDcpBpiName The Name parameter is the name of the package's library file.

Flags contains the flags in the information table for the package.

Param is a user-defined value passed to GetPackageInfo.
 
function GetInfo(const Name: string; NameType: TNameType; Flags: Byte; Param: Pointer): Boolean; stdcall
begin
case NameType of
ntContainsUnit:Form1.memo1.Lines.Add(Name);
ntRequiresPackage:Form1.memo2.Lines.Add(Name);
ntDcpBpiName:Form1.memo3.Lines.Add(Name);
end;
Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
a: HMODULE;
b: Integer;
begin
a := LoadPackage('d:/delphi/components/HX_Grid/HX_NewGrid.bpl');
GetPackageInfo(a,nil,b,@GetInfo);
end;
 
我已有办法了,谢谢诸位。
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部