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 java.util.Arrays;
20  import java.util.List;
21  
22  import com.sun.jna.Library;
23  import com.sun.jna.Native;
24  import com.sun.jna.NativeLong;
25  import com.sun.jna.Pointer;
26  import com.sun.jna.Structure;
27  
28  /**
29   * Power profile stats
30   * 
31   * @author widdis[at]gmail[dot]com
32   */
33  public interface PowrProf extends Library {
34  	PowrProf INSTANCE = (PowrProf) Native.loadLibrary("PowrProf",
35  			PowrProf.class);
36  
37  	public static int SYSTEM_BATTERY_STATE = 5;
38  
39  	public static class SystemBatteryState extends Structure {
40  		public byte acOnLine; // boolean
41  		public byte batteryPresent; // boolean
42  		public byte charging; // boolean
43  		public byte discharging; // boolean
44  		public byte[] spare1 = new byte[4]; // unused
45  		public int maxCapacity; // unsigned 32 bit
46  		public int remainingCapacity; // unsigned 32 bit
47  		public int rate; // signed 32 bit
48  		public int estimatedTime; // signed 32 bit
49  		public int defaultAlert1; // unsigned 32 bit
50  		public int defaultAlert2; // unsigned 32 bit
51  
52  		@Override
53  		protected List<String> getFieldOrder() {
54  			return Arrays.asList(new String[] { "acOnLine", "batteryPresent",
55  					"charging", "discharging", "spare1", "maxCapacity",
56  					"remainingCapacity", "rate", "estimatedTime",
57  					"defaultAlert1", "defaultAlert2" });
58  		}
59  	}
60  
61  	int CallNtPowerInformation(int informationLevel, Pointer lpInputBuffer,
62  			NativeLong nInputBufferSize, Structure lpOutputBuffer,
63  			NativeLong nOutputBufferSize);
64  }