<?php Function _Win_Ffi_GlobalMemoryStatus()
{
static $Kernel32, $a, $r;
$Kernel32??=FFI::cdef(<<<'IDL'
typedef struct _MemoryStatus {
uint32_t Length ;
uint32_t MemoryLoad ;
uint64_t TotalPhys ;
uint64_t AvailPhys ;
uint64_t TotalPageFile ;
uint64_t AvailPageFile ;
uint64_t TotalVirtual ;
uint64_t AvailVirtual ;
} MemoryStatus;
void GlobalMemoryStatus(MemoryStatus* buf);
IDL, 'Kernel32.dll');
$a??=$Kernel32->new('MemoryStatus');
$a->Length =$Kernel32::sizeof($Kernel32->type('MemoryStatus'));
$r??=FFI::addr($a);
$Kernel32->GlobalMemoryStatus($r);
return [
'Total' =>$a->TotalPhys,
'Free' =>$a->TotalPhys-$a->AvailPhys,
'Load' =>$a->MemoryLoad*0.01,
];
}
?>