'https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/ns-sysinfoapi-_system_info
'https://docs.microsoft.com/de-de/windows/desktop/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex
$ filename "SystemInfo.exe"
'uses rtl32
'uses rtl64
uses corewin
uses console
SetConsoleTitle "Return Information about the current System"
type SYSTEM_INFO
union dn {
word wProcessorArchitecture
word wReserved
=
dword dwOemId 'union
}
dword dwPageSize
sys lpMinimumApplicationAddress 'lpvoid
sys lpMaximumApplicationAddress 'lpvoid
sys dwActiveProcessorMask 'dword_ptr
dword dwNumberOfProcessors
dword dwProcessorType
dword dwAllocationGranularity
word wProcessorLevel
word wProcessorRevision
end type
type PROCCESSOR_ARCHITECTURE
int value
string kind
end type
PROCCESSOR_ARCHITECTURE p_a = {
{9,"x64 (AMD or Intel)"},
{5,"ARM"},
{12,"ARM64"},
{6,"Intel Itanium-based"},
{0,"x86"},
{65535,"Unknown architecture"}
}
type MEMORYSTATUSEX
dword dwLength
dword dwMemoryLoad
quad ullTotalPhys
quad ullAvailPhys 'DWORDLONG
quad ullTotalPageFile 'DWORDLONG
quad ullAvailPageFile 'DWORDLONG
quad ullTotalVirtual 'DWORDLONG
quad ullAvailVirtual 'DWORDLONG
quad ullAvailExtendedVirtual 'DWORDLONG
end type
sub systeminfo(SYSTEM_INFO *si)
printl "Number of Processors " si.dwNumberOfProcessors
int x
for x=1 to countof(p_a)
if (p_a[x].value = si.dn.wProcessorArchitecture) then
printl "Processor Architecture: " p_a[x].value & " ==> " p_a[x].kind : exit for
end if
next
printl "Level: " si.wProcessorLevel ", Revision: " si.wProcessorRevision
printl
printl "Page size = " si.dwPageSize
printl "lowest memory address accessible: 0x" hex si.lpMinimumApplicationAddress
printl "highest memory address accessible: 0x" hex si.lpMaximumApplicationAddress
printl "ActiveProcessorMask: " si.dwActiveProcessorMask
printl "Starting address at which virtual memory can be allocated: 0x" hex si.dwAllocationGranularity
end sub
SYSTEM_INFO si
sys GetNativeInfoFunc = GetProcAddress(GetModuleHandle("Kernel32"), "GetNativeSystemInfo")
sys isWow64Func = GetProcAddress(GetModuleHandle("Kernel32"), "IsWow64Process")
if isWoW64Func!=0 then
bool buff
call IsWow64Func(GetCurrentProcess(), @buff)
if buff then
print "Running 32-bit application under WOW64"
printl
call GetNativeInfoFunc(si)
printl "Using GetNativeSystemInfo:"
systeminfo(si)
else
#ifdef mode64bit
print "Running 64-bit application"
printl
GetSystemInfo (si)
printl "Using GetSystemInfo:"
systeminfo(si)
#else
print "Running 32-bit application"
printl
if GetNativeInfoFunc!=0 then
call GetNativeInfoFunc(si)
printl "Using GetNativeSystemInfo:"
systeminfo(si)
else
GetSystemInfo (si)
printl "Using GetSystemInfo:"
systeminfo(si)
end if
#endif
end if
else
'must be 32-bit anyway
print "Running 32-bit application"
printl
GetSystemInfo (si)
printl "Using GetSystemInfo:"
systeminfo(si)
end if
MEMORYSTATUSEX mse
mse.dwLength = sizeof(MEMORYSTATUSEX)
bool ret = GlobalMemoryStatusEx(Mse)
printl
printl "Memory used: " mse.dwMemoryLoad "%"
printl "Total physical memory: " mse.ullTotalPhys/1024 " KB"
printl "Free physical mmemory: " mse.ullAvailPhys/1024 " KB"
printl "Size of total paging file: " mse.ullTotalPageFile/1024 " KB"
printl "Size of free pageing file: " mse.ullAvailPageFile/1024 " KB"
printl "Total virtual memory: " mse.ullTotalVirtual/1024 " KB"
printl "Free virtual memory: " mse.ullAvailVirtual/1024 " KB"
printl "Free extended virtual memory: "mse.ullAvailExtendedVirtual/1024 " KB"
printl
printl "Enter ..."
waitkey