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 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
30
31
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;
41 public byte batteryPresent;
42 public byte charging;
43 public byte discharging;
44 public byte[] spare1 = new byte[4];
45 public int maxCapacity;
46 public int remainingCapacity;
47 public int rate;
48 public int estimatedTime;
49 public int defaultAlert1;
50 public int defaultAlert2;
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 }