How to check if an application (.exe) was created with a runtime package

How can I check in encoding if my .exe Delphi application is built with a runtime package or is a single .exe?

+4
source share
4 answers

Another possibility:

function UsesRuntimePackages: Boolean; begin Result := FindClassHInstance(TObject) <> HInstance; end; 
+8
source

Another possibility, if you need it for an external executable file (without launching):

 procedure InfoProc(const Name: string; NameType: TNameType; Flags: Byte; Param: Pointer); begin case NameType of ntContainsUnit: if Name = 'System' then PBoolean(Param)^ := False; end; end; function UsesRuntimePackages(const ExeName: TFileName): Boolean; var Module: HMODULE; Flags: Integer; begin Result := True; Module := LoadLibraryEx(PChar(ExeName), 0, LOAD_LIBRARY_AS_DATAFILE); try Flags := 0; GetPackageInfo(Module, @Result, Flags, InfoProc); finally FreeLibrary(Module); end; end; 
+2
source

Usage can use the EnumModules() procedure, for example:

 function EnumModuleProc(HInstance: Integer; Data: Pointer): Boolean; begin Result := True; if HInstance <> MainInstance then begin Inc(PInteger(Data)^); Result := False; end; end; function UsesRuntimePackages: boolean; var PckgCount: integer; begin PckgCount := 0; EnumModules(EnumModuleProc, @PckgCount); Result := PckgCount > 0; end; 
+1
source

Have you tried Islibrary?

0
source

Source: https://habr.com/ru/post/1309741/


All Articles