I'm creating a "Version Info" dialog box for my applications; something similar to the one Delphi has in the "About" dialog box. I'd like to display the version information only for the run time packages (.BPL
files), and not all the loaded DLLs. Does the RTL
include functions to get a list of the loaded packages, or I have to use the EnumProcessModules
function and filter the result?
Thanks in advance...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With