View Javadoc
1   /**
2    * Oshi (https://github.com/dblock/oshi)
3    * 
4    * Copyright (c) 2010 - 2015 The Oshi Project Team
5    * 
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Eclipse Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/epl-v10.html
10   * 
11   * Contributors:
12   * dblock[at]dblock[dot]org
13   * alessandro[at]perucchi[dot]org
14   * widdis[at]gmail[dot]com
15   * https://github.com/dblock/oshi/graphs/contributors
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   * Windows OS native system information.
26   * 
27   * @author dblock[at]dblock[dot]org
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  			// no WOW64 support
47  		}
48  
49  		this._si = si;
50  	}
51  
52  	public OSNativeSystemInfo(SYSTEM_INFO si) {
53  		this._si = si;
54  	}
55  
56  	/**
57  	 * Number of processors.
58  	 * 
59  	 * @return Integer.
60  	 */
61  	public int getNumberOfProcessors() {
62  		return this._si.dwNumberOfProcessors.intValue();
63  	}
64  }