Ermitteln der Größe des ArbeitsspeichersOktober 2013
Nützlich für Java-Programme, da dann ein passender Wert für -Xmx vom Setup eingestellt werden kann (im Beispiel unten 3/4 des Gesamtspeichers).
// Get memory size. Note: Might need at least InnoSetup 5.5.3 UNICODE VERSION!
// See http://stackoverflow.com/questions/17026867/inno-setup-how-can-i-check-system-specs-before-during-installation
type
// the following mapping of the DWORDLONG data type is wrong;
// the correct type is a 64-bit unsigned integer which is not
// available in InnoSetup Pascal Script at this time, so max.
// values of the following fields will be limited to quite a
// big reserve of 8589,934.592 GB of RAM; I hope enough for
// the next versions of Windows :-)
DWORDLONG = Int64;
TMemoryStatusEx = record
dwLength: DWORD;
dwMemoryLoad: DWORD;
ullTotalPhys: DWORDLONG;
ullAvailPhys: DWORDLONG;
ullTotalPageFile: DWORDLONG;
ullAvailPageFile: DWORDLONG;
ullTotalVirtual: DWORDLONG;
ullAvailVirtual: DWORDLONG;
ullAvailExtendedVirtual: DWORDLONG;
end;
function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): BOOL;
external 'GlobalMemoryStatusEx@kernel32.dll stdcall';
// get 3/4 of memory size in MB as string containing only numbers
function getThreeForthOfMemoryInMb(): String;
var
MemoryStatus: TMemoryStatusEx;
begin
MemoryStatus.dwLength := SizeOf(MemoryStatus);
GlobalMemoryStatusEx(MemoryStatus)
result := Int64ToStr(MemoryStatus.ullTotalPhys * 3 / 4 / 1024 / 1024)
end;