How may I test in coding if my .exe Delphi application is built with runtime package or is single .exe?
Tried. It doesn't work. Both packaged and non-packaged .exe application return False.
Chau Chee Yang
2010-05-14 07:24:23
An EXE is never a library.
Oliver Giesen
2010-05-14 08:08:38
+1
A:
Use could use the EnumModules()
procedure, like so:
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;
mghie
2010-05-14 08:17:16
+5
A:
Another possibility:
function UsesRuntimePackages: Boolean;
begin
Result := FindClassHInstance(TObject) <> HInstance;
end;
TOndrej
2010-05-14 08:36:27
+1
A:
Another possibility, in case you need this for an external executable (without running it):
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;
TOndrej
2010-05-14 09:14:47