1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package oshi.software.os.windows.nt;
18
19 import com.sun.jna.platform.win32.Kernel32;
20 import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
21 import com.sun.jna.platform.win32.WinNT.HANDLE;
22 import com.sun.jna.ptr.IntByReference;
23
24
25
26
27
28
29 public class OSNativeSystemInfo {
30 private SYSTEM_INFO _si = null;
31
32 public OSNativeSystemInfo() {
33
34 SYSTEM_INFO si = new SYSTEM_INFO();
35 Kernel32.INSTANCE.GetSystemInfo(si);
36
37 try {
38 IntByReference isWow64 = new IntByReference();
39 HANDLE hProcess = Kernel32.INSTANCE.GetCurrentProcess();
40 if (Kernel32.INSTANCE.IsWow64Process(hProcess, isWow64)) {
41 if (isWow64.getValue() > 0) {
42 Kernel32.INSTANCE.GetNativeSystemInfo(si);
43 }
44 }
45 } catch (UnsatisfiedLinkError e) {
46
47 }
48
49 this._si = si;
50 }
51
52 public OSNativeSystemInfo(SYSTEM_INFO si) {
53 this._si = si;
54 }
55
56
57
58
59
60
61 public int getNumberOfProcessors() {
62 return this._si.dwNumberOfProcessors.intValue();
63 }
64 }