How to get a list of downloaded runtime packages?

I am creating a Version Information dialog box for my applications; something similar to what Delphi has in the About dialog box. I would like to display version information only for runtime packages ( .BPL), and not for all loaded DLLs. Does RTLit include functions to get the list of downloaded packages, or should I use the function EnumProcessModulesand filter the result?

Thanks in advance...

+5
source share
1 answer

You can use the EnumModules function System.

, EnumModules BPL's. , . , , :

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.
+7

All Articles