1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.strings
4 kernel libc math namespaces system-info.backend
5 system-info.windows windows windows.advapi32
6 windows.kernel32 system byte-arrays ;
7 IN: system-info.windows.nt
10 system-info SYSTEM_INFO-dwNumberOfProcessors ;
12 : memory-status ( -- MEMORYSTATUSEX )
13 "MEMORYSTATUSEX" <c-object>
14 "MEMORYSTATUSEX" heap-size over set-MEMORYSTATUSEX-dwLength
15 dup GlobalMemoryStatusEx win32-error=0/f ;
17 M: winnt memory-load ( -- n )
18 memory-status MEMORYSTATUSEX-dwMemoryLoad ;
20 M: winnt physical-mem ( -- n )
21 memory-status MEMORYSTATUSEX-ullTotalPhys ;
23 M: winnt available-mem ( -- n )
24 memory-status MEMORYSTATUSEX-ullAvailPhys ;
26 M: winnt total-page-file ( -- n )
27 memory-status MEMORYSTATUSEX-ullTotalPageFile ;
29 M: winnt available-page-file ( -- n )
30 memory-status MEMORYSTATUSEX-ullAvailPageFile ;
32 M: winnt total-virtual-mem ( -- n )
33 memory-status MEMORYSTATUSEX-ullTotalVirtual ;
35 M: winnt available-virtual-mem ( -- n )
36 memory-status MEMORYSTATUSEX-ullAvailVirtual ;
38 : computer-name ( -- string )
39 MAX_COMPUTERNAME_LENGTH 1+
40 [ <byte-array> dup ] keep <uint>
41 GetComputerName win32-error=0/f alien>native-string ;
43 : username ( -- string )
45 [ <byte-array> dup ] keep <uint>
46 GetUserName win32-error=0/f alien>native-string ;