]> gitweb.factorcode.org Git - factor.git/blob - basis/system-info/windows/nt/nt.factor
Updating code to use with-out-parameters
[factor.git] / basis / system-info / windows / nt / nt.factor
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 windows.errors
7 classes classes.struct accessors ;
8 IN: system-info.windows.nt
9
10 M: winnt cpus ( -- n )
11     system-info dwNumberOfProcessors>> ;
12
13 : memory-status ( -- MEMORYSTATUSEX )
14     MEMORYSTATUSEX <struct>
15     MEMORYSTATUSEX heap-size >>dwLength
16     dup GlobalMemoryStatusEx win32-error=0/f ;
17
18 M: winnt memory-load ( -- n )
19     memory-status dwMemoryLoad>> ;
20
21 M: winnt physical-mem ( -- n )
22     memory-status ullTotalPhys>> ;
23
24 M: winnt available-mem ( -- n )
25     memory-status ullAvailPhys>> ;
26
27 M: winnt total-page-file ( -- n )
28     memory-status ullTotalPageFile>> ;
29
30 M: winnt available-page-file ( -- n )
31     memory-status ullAvailPageFile>> ;
32
33 M: winnt total-virtual-mem ( -- n )
34     memory-status ullTotalVirtual>> ;
35
36 M: winnt available-virtual-mem ( -- n )
37     memory-status ullAvailVirtual>> ;
38
39 : computer-name ( -- string )
40     MAX_COMPUTERNAME_LENGTH 1 +
41     [ <byte-array> dup ] keep <uint>
42     GetComputerName win32-error=0/f alien>native-string ;
43  
44 : username ( -- string )
45     UNLEN 1 +
46     [ <byte-array> dup ] keep <uint>
47     GetUserName win32-error=0/f alien>native-string ;