Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check which .bpl package an object belongs to

Tags:

delphi

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?

like image 691
Chau Chee Yang Avatar asked Nov 22 '10 07:11

Chau Chee Yang


1 Answers

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);
like image 197
Dan Bartlett Avatar answered Sep 22 '22 07:09

Dan Bartlett