You can use the EnumModules function from System
.
Here's a very simple demonstration of how to use the EnumModules
function and get the names of all the loaded BPL's
. It's a console application, but the code can be easily reused in a production application. If you want to test it out, make sure you're using packages:
program Project17;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes, Windows;
function EnumModulesFunc(HInstance: Integer; Data: Pointer): Boolean;
var Buff:array[0..1023] of char;
begin
if GetModuleFileName(HInstance, @Buff, SizeOf(Buff)) = ERROR_INSUFFICIENT_BUFFER then
Buff[High(Buff)] := #0;
TStringList(Data).Add(Buff);
end;
var L: TStringList;
begin
try
L := TStringList.Create;
try
System.EnumModules(EnumModulesFunc, L);
WriteLn(L.Text);
finally L.Free;
end;
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.