cstruct 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -0
- data/cstruct.gemspec +10 -0
- data/doc/examples/anonymous_struct.rb.html +94 -94
- data/doc/examples/anonymous_union.rb.html +93 -93
- data/doc/examples/array_member.rb.html +79 -79
- data/doc/examples/file_io.rb.html +87 -87
- data/doc/examples/first_example.rb.html +104 -104
- data/doc/examples/get_system_info.rb.html +114 -114
- data/doc/examples/get_versionex.rb.html +97 -97
- data/doc/examples/global_memory.rb.html +102 -102
- data/doc/examples/inner_struct.rb.html +79 -79
- data/doc/examples/inner_union.rb.html +77 -77
- data/doc/examples/namespace.rb.html +80 -80
- data/doc/examples/show_processes.rb.html +95 -95
- data/doc/examples/struct_member.rb.html +128 -128
- data/doc/stylesheets/ie.css +8 -8
- data/examples/anonymous_struct.rb +6 -6
- data/examples/anonymous_union.rb +5 -5
- data/examples/array_member.rb +1 -1
- data/examples/file_io.rb +22 -23
- data/examples/first_example.rb +4 -4
- data/examples/inner_struct.rb +5 -5
- data/examples/inner_union.rb +4 -4
- data/examples/namespace.rb +15 -15
- data/examples/win32/get_system_info.rb +31 -31
- data/examples/win32/get_versionex.rb +12 -12
- data/examples/win32/global_memory.rb +9 -9
- data/examples/win32/show_processes.rb +28 -28
- data/lib/cstruct.rb +1 -523
- data/lib/cstruct/cstruct.rb +457 -0
- data/lib/cstruct/field.rb +45 -0
- data/lib/cstruct/utils.rb +53 -0
- data/lib/cstruct/win32struct.rb +84 -0
- data/lib/cstruct/win64struct.rb +5 -0
- data/lib/win32struct.rb +3 -90
- data/lib/win64struct.rb +3 -13
- data/spec/cstruct_spec.rb +240 -0
- metadata +62 -73
@@ -1,114 +1,114 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:GetSystemInfo</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">windows/system_info</span><span class="dl">'</span></span>
|
49
|
-
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
-
include <span class="co">Windows</span>::<span class="co">SystemInfo</span>
|
51
|
-
|
52
|
-
<span class="c"># SYSTEM_INFO in VC6 's SDK</span>
|
53
|
-
<span class="c"># typedef struct _SYSTEM_INFO {</span>
|
54
|
-
<span class="c"># union {</span>
|
55
|
-
<span class="c"># DWORD dwOemId; // Obsolete field...do not use</span>
|
56
|
-
<span class="c"># struct {</span>
|
57
|
-
<span class="c"># WORD wProcessorArchitecture;</span>
|
58
|
-
<span class="c"># WORD wReserved;</span>
|
59
|
-
<span class="c"># };</span>
|
60
|
-
<span class="c"># };</span>
|
61
|
-
<span class="c"># DWORD dwPageSize;</span>
|
62
|
-
<span class="c"># LPVOID lpMinimumApplicationAddress;</span>
|
63
|
-
<span class="c"># LPVOID lpMaximumApplicationAddress;</span>
|
64
|
-
<span class="c"># DWORD dwActiveProcessorMask;</span>
|
65
|
-
<span class="c"># DWORD dwNumberOfProcessors;</span>
|
66
|
-
<span class="c"># DWORD dwProcessorType;</span>
|
67
|
-
<span class="c"># DWORD dwAllocationGranularity;</span>
|
68
|
-
<span class="c"># WORD wProcessorLevel;</span>
|
69
|
-
<span class="c"># WORD wProcessorRevision;</span>
|
70
|
-
<span class="c"># } SYSTEM_INFO, *LPSYSTEM_INFO;</span>
|
71
|
-
|
72
|
-
<span class="c"># SYSTEM_INFO in Ruby</span>
|
73
|
-
<span class="r">class</span> <span class="cl">SYSTEM_INFO</span> < <span class="co">Win32Struct</span>
|
74
|
-
union<span class="sy">:u</span> <span class="r">do</span>
|
75
|
-
<span class="co">DWORD</span><span class="sy">:dwOemId</span>
|
76
|
-
struct<span class="sy">:x</span> <span class="r">do</span>
|
77
|
-
<span class="co">WORD</span><span class="sy">:wProcessorArchitecture</span>
|
78
|
-
<span class="co">WORD</span><span class="sy">:wReserved</span>
|
79
|
-
<span class="r">end</span>
|
80
|
-
<span class="r">end</span>
|
81
|
-
<span class="co">DWORD</span> <span class="sy">:dwPageSize</span>
|
82
|
-
<span class="co">LPVOID</span> <span class="sy">:lpMinimumApplicationAddress</span>
|
83
|
-
<span class="co">LPVOID</span> <span class="sy">:lpMaximumApplicationAddress</span>
|
84
|
-
<span class="co">DWORD</span> <span class="sy">:dwActiveProcessorMask</span>
|
85
|
-
<span class="co">DWORD</span> <span class="sy">:dwNumberOfProcessors</span>
|
86
|
-
<span class="co">DWORD</span> <span class="sy">:dwProcessorType</span>
|
87
|
-
<span class="co">DWORD</span> <span class="sy">:dwAllocationGranularity</span>
|
88
|
-
<span class="co">WORD</span> <span class="sy">:wProcessorLevel</span>
|
89
|
-
<span class="co">WORD</span> <span class="sy">:wProcessorRevision</span>
|
90
|
-
<span class="r">end</span>
|
91
|
-
|
92
|
-
<span class="c"># call GetSystemInfo</span>
|
93
|
-
sys_info = <span class="co">SYSTEM_INFO</span>.new
|
94
|
-
GetSystemInfo(sys_info.__data__) <span class="c"># __data__ is an alias for method 'data' </span>
|
95
|
-
|
96
|
-
<span class="c">#output</span>
|
97
|
-
puts <span class="s"><span class="dl">"</span><span class="k"><System Infomation></span><span class="dl">"</span></span>
|
98
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Processor Architecture:</span><span class="il"><span class="idl">#{</span>sys_info.u.x.wProcessorArchitecture<span class="idl">}</span></span><span class="dl">"</span></span> <span class="c"># 'u' and 'x' can not be omitted</span>
|
99
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Page Size:</span><span class="il"><span class="idl">#{</span>sys_info.dwPageSize<span class="idl">}</span></span><span class="dl">"</span></span>
|
100
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Minimum Application Address:0x</span><span class="il"><span class="idl">#{</span>sys_info.lpMinimumApplicationAddress.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
101
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Maximum Application Address:0x</span><span class="il"><span class="idl">#{</span>sys_info.lpMaximumApplicationAddress.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
102
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Active Processor Mask:</span><span class="il"><span class="idl">#{</span>sys_info.dwActiveProcessorMask<span class="idl">}</span></span><span class="dl">"</span></span>
|
103
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Number Of Processors:</span><span class="il"><span class="idl">#{</span>sys_info.dwNumberOfProcessors<span class="idl">}</span></span><span class="dl">"</span></span>
|
104
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Processor Type:</span><span class="il"><span class="idl">#{</span>sys_info.dwProcessorType<span class="idl">}</span></span><span class="dl">"</span></span>
|
105
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Allocation Granularity:0x</span><span class="il"><span class="idl">#{</span>sys_info.dwAllocationGranularity.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
106
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Processor Level:</span><span class="il"><span class="idl">#{</span>sys_info.wProcessorLevel<span class="idl">}</span></span><span class="dl">"</span></span>
|
107
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Processor Revision:</span><span class="il"><span class="idl">#{</span>sys_info.wProcessorRevision<span class="idl">}</span></span><span class="dl">"</span></span>
|
108
|
-
|
109
|
-
|
110
|
-
</pre></div>
|
111
|
-
</div>
|
112
|
-
|
113
|
-
</div>
|
114
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:GetSystemInfo</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">windows/system_info</span><span class="dl">'</span></span>
|
49
|
+
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
+
include <span class="co">Windows</span>::<span class="co">SystemInfo</span>
|
51
|
+
|
52
|
+
<span class="c"># SYSTEM_INFO in VC6 's SDK</span>
|
53
|
+
<span class="c"># typedef struct _SYSTEM_INFO {</span>
|
54
|
+
<span class="c"># union {</span>
|
55
|
+
<span class="c"># DWORD dwOemId; // Obsolete field...do not use</span>
|
56
|
+
<span class="c"># struct {</span>
|
57
|
+
<span class="c"># WORD wProcessorArchitecture;</span>
|
58
|
+
<span class="c"># WORD wReserved;</span>
|
59
|
+
<span class="c"># };</span>
|
60
|
+
<span class="c"># };</span>
|
61
|
+
<span class="c"># DWORD dwPageSize;</span>
|
62
|
+
<span class="c"># LPVOID lpMinimumApplicationAddress;</span>
|
63
|
+
<span class="c"># LPVOID lpMaximumApplicationAddress;</span>
|
64
|
+
<span class="c"># DWORD dwActiveProcessorMask;</span>
|
65
|
+
<span class="c"># DWORD dwNumberOfProcessors;</span>
|
66
|
+
<span class="c"># DWORD dwProcessorType;</span>
|
67
|
+
<span class="c"># DWORD dwAllocationGranularity;</span>
|
68
|
+
<span class="c"># WORD wProcessorLevel;</span>
|
69
|
+
<span class="c"># WORD wProcessorRevision;</span>
|
70
|
+
<span class="c"># } SYSTEM_INFO, *LPSYSTEM_INFO;</span>
|
71
|
+
|
72
|
+
<span class="c"># SYSTEM_INFO in Ruby</span>
|
73
|
+
<span class="r">class</span> <span class="cl">SYSTEM_INFO</span> < <span class="co">Win32Struct</span>
|
74
|
+
union<span class="sy">:u</span> <span class="r">do</span>
|
75
|
+
<span class="co">DWORD</span><span class="sy">:dwOemId</span>
|
76
|
+
struct<span class="sy">:x</span> <span class="r">do</span>
|
77
|
+
<span class="co">WORD</span><span class="sy">:wProcessorArchitecture</span>
|
78
|
+
<span class="co">WORD</span><span class="sy">:wReserved</span>
|
79
|
+
<span class="r">end</span>
|
80
|
+
<span class="r">end</span>
|
81
|
+
<span class="co">DWORD</span> <span class="sy">:dwPageSize</span>
|
82
|
+
<span class="co">LPVOID</span> <span class="sy">:lpMinimumApplicationAddress</span>
|
83
|
+
<span class="co">LPVOID</span> <span class="sy">:lpMaximumApplicationAddress</span>
|
84
|
+
<span class="co">DWORD</span> <span class="sy">:dwActiveProcessorMask</span>
|
85
|
+
<span class="co">DWORD</span> <span class="sy">:dwNumberOfProcessors</span>
|
86
|
+
<span class="co">DWORD</span> <span class="sy">:dwProcessorType</span>
|
87
|
+
<span class="co">DWORD</span> <span class="sy">:dwAllocationGranularity</span>
|
88
|
+
<span class="co">WORD</span> <span class="sy">:wProcessorLevel</span>
|
89
|
+
<span class="co">WORD</span> <span class="sy">:wProcessorRevision</span>
|
90
|
+
<span class="r">end</span>
|
91
|
+
|
92
|
+
<span class="c"># call GetSystemInfo</span>
|
93
|
+
sys_info = <span class="co">SYSTEM_INFO</span>.new
|
94
|
+
GetSystemInfo(sys_info.__data__) <span class="c"># __data__ is an alias for method 'data' </span>
|
95
|
+
|
96
|
+
<span class="c">#output</span>
|
97
|
+
puts <span class="s"><span class="dl">"</span><span class="k"><System Infomation></span><span class="dl">"</span></span>
|
98
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Processor Architecture:</span><span class="il"><span class="idl">#{</span>sys_info.u.x.wProcessorArchitecture<span class="idl">}</span></span><span class="dl">"</span></span> <span class="c"># 'u' and 'x' can not be omitted</span>
|
99
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Page Size:</span><span class="il"><span class="idl">#{</span>sys_info.dwPageSize<span class="idl">}</span></span><span class="dl">"</span></span>
|
100
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Minimum Application Address:0x</span><span class="il"><span class="idl">#{</span>sys_info.lpMinimumApplicationAddress.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
101
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Maximum Application Address:0x</span><span class="il"><span class="idl">#{</span>sys_info.lpMaximumApplicationAddress.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
102
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Active Processor Mask:</span><span class="il"><span class="idl">#{</span>sys_info.dwActiveProcessorMask<span class="idl">}</span></span><span class="dl">"</span></span>
|
103
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Number Of Processors:</span><span class="il"><span class="idl">#{</span>sys_info.dwNumberOfProcessors<span class="idl">}</span></span><span class="dl">"</span></span>
|
104
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Processor Type:</span><span class="il"><span class="idl">#{</span>sys_info.dwProcessorType<span class="idl">}</span></span><span class="dl">"</span></span>
|
105
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Allocation Granularity:0x</span><span class="il"><span class="idl">#{</span>sys_info.dwAllocationGranularity.to_s <span class="i">16</span><span class="idl">}</span></span><span class="dl">"</span></span>
|
106
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Processor Level:</span><span class="il"><span class="idl">#{</span>sys_info.wProcessorLevel<span class="idl">}</span></span><span class="dl">"</span></span>
|
107
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Processor Revision:</span><span class="il"><span class="idl">#{</span>sys_info.wProcessorRevision<span class="idl">}</span></span><span class="dl">"</span></span>
|
108
|
+
|
109
|
+
|
110
|
+
</pre></div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</body>
|
@@ -1,97 +1,97 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:GetVersionExA</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">windows/system_info</span><span class="dl">'</span></span>
|
49
|
-
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
-
include <span class="co">Windows</span>::<span class="co">SystemInfo</span>
|
51
|
-
|
52
|
-
|
53
|
-
<span class="c"># OSVERSIONINFOEXA in VC6 's SDK</span>
|
54
|
-
<span class="c">#typedef struct _OSVERSIONINFOEXA {</span>
|
55
|
-
<span class="c"># DWORD dwOSVersionInfoSize;</span>
|
56
|
-
<span class="c"># DWORD dwMajorVersion;</span>
|
57
|
-
<span class="c"># DWORD dwMinorVersion;</span>
|
58
|
-
<span class="c"># DWORD dwBuildNumber;</span>
|
59
|
-
<span class="c"># DWORD dwPlatformId;</span>
|
60
|
-
<span class="c"># CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage</span>
|
61
|
-
<span class="c"># WORD wServicePackMajor;</span>
|
62
|
-
<span class="c"># WORD wServicePackMinor;</span>
|
63
|
-
<span class="c"># WORD wReserved[2];</span>
|
64
|
-
<span class="c">#} OSVERSIONINFOEXA;</span>
|
65
|
-
|
66
|
-
|
67
|
-
<span class="r">class</span> <span class="cl">OSVERSIONINFOEXA</span> < <span class="co">Win32Struct</span>
|
68
|
-
<span class="co">DWORD</span> <span class="sy">:dwOSVersionInfoSize</span>
|
69
|
-
<span class="co">DWORD</span> <span class="sy">:dwMajorVersion</span>
|
70
|
-
<span class="co">DWORD</span> <span class="sy">:dwMinorVersion</span>
|
71
|
-
<span class="co">DWORD</span> <span class="sy">:dwBuildNumber</span>
|
72
|
-
<span class="co">DWORD</span> <span class="sy">:dwPlatformId</span>
|
73
|
-
<span class="co">CHAR</span> <span class="sy">:szCSDVersion</span>,[ <span class="i">128</span> ]
|
74
|
-
<span class="co">WORD</span> <span class="sy">:wServicePackMajor</span>
|
75
|
-
<span class="co">WORD</span> <span class="sy">:wServicePackMinor</span>
|
76
|
-
<span class="co">WORD</span> <span class="sy">:wReserved</span>,[<span class="i">2</span>]
|
77
|
-
<span class="r">end</span>
|
78
|
-
|
79
|
-
ver_info_ex = <span class="co">OSVERSIONINFOEXA</span>.new <span class="r">do</span> |st|
|
80
|
-
st.dwOSVersionInfoSize = <span class="co">OSVERSIONINFOEXA</span>.__size__ <span class="c"># __size__ is an alias for method 'size'</span>
|
81
|
-
<span class="r">end</span>
|
82
|
-
|
83
|
-
<span class="c">#ANSI Version: GetVersionExA</span>
|
84
|
-
GetVersionExA(ver_info_ex.__data__) <span class="c"># __data__ is an alias for method 'data'</span>
|
85
|
-
|
86
|
-
puts <span class="s"><span class="dl">"</span><span class="k"><OS Version Infomation></span><span class="dl">"</span></span>
|
87
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Major Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwMajorVersion<span class="idl">}</span></span><span class="dl">"</span></span>
|
88
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Minor Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwMinorVersion<span class="idl">}</span></span><span class="dl">"</span></span>
|
89
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Build Number:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwBuildNumber<span class="idl">}</span></span><span class="dl">"</span></span>
|
90
|
-
puts <span class="s"><span class="dl">"</span><span class="k">Platform Id:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwPlatformId<span class="idl">}</span></span><span class="dl">"</span></span>
|
91
|
-
puts <span class="s"><span class="dl">"</span><span class="k">CSD Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.szCSDVersion.to_cstr<span class="idl">}</span></span><span class="dl">"</span></span> <span class="c"># to_cstr return a string(C Style)</span>
|
92
|
-
puts <span class="s"><span class="dl">"</span><span class="k">ServicePack Major:</span><span class="il"><span class="idl">#{</span>ver_info_ex.wServicePackMajor<span class="idl">}</span></span><span class="dl">"</span></span>
|
93
|
-
puts <span class="s"><span class="dl">"</span><span class="k">ServicePack Minor:</span><span class="il"><span class="idl">#{</span>ver_info_ex.wServicePackMinor<span class="idl">}</span></span><span class="dl">"</span></span></pre></div>
|
94
|
-
</div>
|
95
|
-
|
96
|
-
</div>
|
97
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:GetVersionExA</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">windows/system_info</span><span class="dl">'</span></span>
|
49
|
+
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
+
include <span class="co">Windows</span>::<span class="co">SystemInfo</span>
|
51
|
+
|
52
|
+
|
53
|
+
<span class="c"># OSVERSIONINFOEXA in VC6 's SDK</span>
|
54
|
+
<span class="c">#typedef struct _OSVERSIONINFOEXA {</span>
|
55
|
+
<span class="c"># DWORD dwOSVersionInfoSize;</span>
|
56
|
+
<span class="c"># DWORD dwMajorVersion;</span>
|
57
|
+
<span class="c"># DWORD dwMinorVersion;</span>
|
58
|
+
<span class="c"># DWORD dwBuildNumber;</span>
|
59
|
+
<span class="c"># DWORD dwPlatformId;</span>
|
60
|
+
<span class="c"># CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage</span>
|
61
|
+
<span class="c"># WORD wServicePackMajor;</span>
|
62
|
+
<span class="c"># WORD wServicePackMinor;</span>
|
63
|
+
<span class="c"># WORD wReserved[2];</span>
|
64
|
+
<span class="c">#} OSVERSIONINFOEXA;</span>
|
65
|
+
|
66
|
+
|
67
|
+
<span class="r">class</span> <span class="cl">OSVERSIONINFOEXA</span> < <span class="co">Win32Struct</span>
|
68
|
+
<span class="co">DWORD</span> <span class="sy">:dwOSVersionInfoSize</span>
|
69
|
+
<span class="co">DWORD</span> <span class="sy">:dwMajorVersion</span>
|
70
|
+
<span class="co">DWORD</span> <span class="sy">:dwMinorVersion</span>
|
71
|
+
<span class="co">DWORD</span> <span class="sy">:dwBuildNumber</span>
|
72
|
+
<span class="co">DWORD</span> <span class="sy">:dwPlatformId</span>
|
73
|
+
<span class="co">CHAR</span> <span class="sy">:szCSDVersion</span>,[ <span class="i">128</span> ]
|
74
|
+
<span class="co">WORD</span> <span class="sy">:wServicePackMajor</span>
|
75
|
+
<span class="co">WORD</span> <span class="sy">:wServicePackMinor</span>
|
76
|
+
<span class="co">WORD</span> <span class="sy">:wReserved</span>,[<span class="i">2</span>]
|
77
|
+
<span class="r">end</span>
|
78
|
+
|
79
|
+
ver_info_ex = <span class="co">OSVERSIONINFOEXA</span>.new <span class="r">do</span> |st|
|
80
|
+
st.dwOSVersionInfoSize = <span class="co">OSVERSIONINFOEXA</span>.__size__ <span class="c"># __size__ is an alias for method 'size'</span>
|
81
|
+
<span class="r">end</span>
|
82
|
+
|
83
|
+
<span class="c">#ANSI Version: GetVersionExA</span>
|
84
|
+
GetVersionExA(ver_info_ex.__data__) <span class="c"># __data__ is an alias for method 'data'</span>
|
85
|
+
|
86
|
+
puts <span class="s"><span class="dl">"</span><span class="k"><OS Version Infomation></span><span class="dl">"</span></span>
|
87
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Major Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwMajorVersion<span class="idl">}</span></span><span class="dl">"</span></span>
|
88
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Minor Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwMinorVersion<span class="idl">}</span></span><span class="dl">"</span></span>
|
89
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Build Number:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwBuildNumber<span class="idl">}</span></span><span class="dl">"</span></span>
|
90
|
+
puts <span class="s"><span class="dl">"</span><span class="k">Platform Id:</span><span class="il"><span class="idl">#{</span>ver_info_ex.dwPlatformId<span class="idl">}</span></span><span class="dl">"</span></span>
|
91
|
+
puts <span class="s"><span class="dl">"</span><span class="k">CSD Version:</span><span class="il"><span class="idl">#{</span>ver_info_ex.szCSDVersion.to_cstr<span class="idl">}</span></span><span class="dl">"</span></span> <span class="c"># to_cstr return a string(C Style)</span>
|
92
|
+
puts <span class="s"><span class="dl">"</span><span class="k">ServicePack Major:</span><span class="il"><span class="idl">#{</span>ver_info_ex.wServicePackMajor<span class="idl">}</span></span><span class="dl">"</span></span>
|
93
|
+
puts <span class="s"><span class="dl">"</span><span class="k">ServicePack Minor:</span><span class="il"><span class="idl">#{</span>ver_info_ex.wServicePackMinor<span class="idl">}</span></span><span class="dl">"</span></span></pre></div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
</body>
|
@@ -1,102 +1,102 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:GlobalMemoryStatus</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">windows/memory</span><span class="dl">'</span></span>
|
49
|
-
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
-
|
51
|
-
include <span class="co">Windows</span>::<span class="co">Memory</span>
|
52
|
-
|
53
|
-
<span class="c"># example:</span>
|
54
|
-
|
55
|
-
<span class="c"># typedef struct _MEMORYSTATUS {</span>
|
56
|
-
<span class="c"># DWORD dwLength;</span>
|
57
|
-
<span class="c"># DWORD dwMemoryLoad;</span>
|
58
|
-
<span class="c"># DWORD dwTotalPhys;</span>
|
59
|
-
<span class="c"># DWORD dwAvailPhys;</span>
|
60
|
-
<span class="c"># DWORD dwTotalPageFile;</span>
|
61
|
-
<span class="c"># DWORD dwAvailPageFile;</span>
|
62
|
-
<span class="c"># DWORD dwTotalVirtual;</span>
|
63
|
-
<span class="c"># DWORD dwAvailVirtual;</span>
|
64
|
-
<span class="c"># } MEMORYSTATUS, *LPMEMORYSTATUS;</span>
|
65
|
-
|
66
|
-
<span class="r">class</span> <span class="cl">MEMORYSTATUS</span> < <span class="co">Win32Struct</span>
|
67
|
-
<span class="co">DWORD</span> <span class="sy">:dwLength</span>
|
68
|
-
<span class="co">DWORD</span> <span class="sy">:dwMemoryLoad</span>
|
69
|
-
<span class="co">DWORD</span> <span class="sy">:dwTotalPhys</span>
|
70
|
-
<span class="co">DWORD</span> <span class="sy">:dwAvailPhys</span>
|
71
|
-
<span class="co">DWORD</span> <span class="sy">:dwTotalPageFile</span>
|
72
|
-
<span class="co">DWORD</span> <span class="sy">:dwAvailPageFile</span>
|
73
|
-
<span class="co">DWORD</span> <span class="sy">:dwTotalVirtual</span>
|
74
|
-
<span class="co">DWORD</span> <span class="sy">:dwAvailVirtual</span>
|
75
|
-
<span class="r">end</span>
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<span class="c"># create a MEMORYSTATUS's instance</span>
|
80
|
-
stat = <span class="co">MEMORYSTATUS</span>.new {|st| st.dwLength = <span class="co">MEMORYSTATUS</span>.size }
|
81
|
-
|
82
|
-
<span class="c"># call API "GlobalMemoryStatus" - See also MSDN</span>
|
83
|
-
GlobalMemoryStatus(stat.data)
|
84
|
-
|
85
|
-
<span class="c">#output</span>
|
86
|
-
printf <span class="s"><span class="dl">"</span><span class="k">[Physical Memory]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
87
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalPhys
|
88
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailPhys
|
89
|
-
|
90
|
-
printf <span class="s"><span class="dl">"</span><span class="k">[Virtual Memory]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
91
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalVirtual
|
92
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailVirtual
|
93
|
-
|
94
|
-
printf <span class="s"><span class="dl">"</span><span class="k">[Paging File]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
95
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalPageFile
|
96
|
-
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailPageFile
|
97
|
-
|
98
|
-
</pre></div>
|
99
|
-
</div>
|
100
|
-
|
101
|
-
</div>
|
102
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:GlobalMemoryStatus</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">windows/memory</span><span class="dl">'</span></span>
|
49
|
+
require <span class="s"><span class="dl">'</span><span class="k">win32struct</span><span class="dl">'</span></span>
|
50
|
+
|
51
|
+
include <span class="co">Windows</span>::<span class="co">Memory</span>
|
52
|
+
|
53
|
+
<span class="c"># example:</span>
|
54
|
+
|
55
|
+
<span class="c"># typedef struct _MEMORYSTATUS {</span>
|
56
|
+
<span class="c"># DWORD dwLength;</span>
|
57
|
+
<span class="c"># DWORD dwMemoryLoad;</span>
|
58
|
+
<span class="c"># DWORD dwTotalPhys;</span>
|
59
|
+
<span class="c"># DWORD dwAvailPhys;</span>
|
60
|
+
<span class="c"># DWORD dwTotalPageFile;</span>
|
61
|
+
<span class="c"># DWORD dwAvailPageFile;</span>
|
62
|
+
<span class="c"># DWORD dwTotalVirtual;</span>
|
63
|
+
<span class="c"># DWORD dwAvailVirtual;</span>
|
64
|
+
<span class="c"># } MEMORYSTATUS, *LPMEMORYSTATUS;</span>
|
65
|
+
|
66
|
+
<span class="r">class</span> <span class="cl">MEMORYSTATUS</span> < <span class="co">Win32Struct</span>
|
67
|
+
<span class="co">DWORD</span> <span class="sy">:dwLength</span>
|
68
|
+
<span class="co">DWORD</span> <span class="sy">:dwMemoryLoad</span>
|
69
|
+
<span class="co">DWORD</span> <span class="sy">:dwTotalPhys</span>
|
70
|
+
<span class="co">DWORD</span> <span class="sy">:dwAvailPhys</span>
|
71
|
+
<span class="co">DWORD</span> <span class="sy">:dwTotalPageFile</span>
|
72
|
+
<span class="co">DWORD</span> <span class="sy">:dwAvailPageFile</span>
|
73
|
+
<span class="co">DWORD</span> <span class="sy">:dwTotalVirtual</span>
|
74
|
+
<span class="co">DWORD</span> <span class="sy">:dwAvailVirtual</span>
|
75
|
+
<span class="r">end</span>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<span class="c"># create a MEMORYSTATUS's instance</span>
|
80
|
+
stat = <span class="co">MEMORYSTATUS</span>.new {|st| st.dwLength = <span class="co">MEMORYSTATUS</span>.size }
|
81
|
+
|
82
|
+
<span class="c"># call API "GlobalMemoryStatus" - See also MSDN</span>
|
83
|
+
GlobalMemoryStatus(stat.data)
|
84
|
+
|
85
|
+
<span class="c">#output</span>
|
86
|
+
printf <span class="s"><span class="dl">"</span><span class="k">[Physical Memory]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
87
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalPhys
|
88
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailPhys
|
89
|
+
|
90
|
+
printf <span class="s"><span class="dl">"</span><span class="k">[Virtual Memory]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
91
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalVirtual
|
92
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailVirtual
|
93
|
+
|
94
|
+
printf <span class="s"><span class="dl">"</span><span class="k">[Paging File]</span><span class="ch">\n</span><span class="dl">"</span></span>
|
95
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> total:%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwTotalPageFile
|
96
|
+
printf <span class="s"><span class="dl">"</span><span class="k"> free :%12d bytes</span><span class="ch">\n</span><span class="dl">"</span></span>,stat.dwAvailPageFile
|
97
|
+
|
98
|
+
</pre></div>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
</body>
|