Chau Chee Yang
Chau Chee Yang

Reputation: 19670

How to check which .bpl package an object belongs to

My Win32 application is built with runtime packages. We may always use HInstance as a reference to know the runtime package of current execution point for a process.

My application may load few runtime packages at runtime. Given an object, is that possible to know which runtime package (or package THandle) the object (or class) belongs to?

Upvotes: 5

Views: 468

Answers (1)

Dan Bartlett
Dan Bartlett

Reputation: 826

You can use FindClassHInstance for this, but whether it returns a package or the exe file will depend upon whether you build with runtime packages or not.

var
  instance: HMODULE;
begin
  instance := FindClassHInstance(TButton);
  Caption := GetModuleName(instance);

Upvotes: 10

Related Questions