30
30
import com .sun .jna .Structure .FieldOrder ;
31
31
import com .sun .jna .Union ;
32
32
import com .sun .jna .platform .win32 .BaseTSD .ULONG_PTR ;
33
- import com .sun .jna .platform .win32 .WinDef .HKL ;
34
33
import com .sun .jna .platform .win32 .WinNT .HANDLE ;
35
34
import com .sun .jna .win32 .StdCallLibrary .StdCallCallback ;
36
35
import com .sun .jna .win32 .W32APITypeMapper ;
@@ -2088,4 +2087,79 @@ public String toString() {
2088
2087
* Bitmask for the RESERVED2 key modifier.
2089
2088
*/
2090
2089
int MODIFIER_RESERVED2_MASK = 32 ;
2090
+
2091
+ class HPOWERNOTIFY extends PVOID {
2092
+ public HPOWERNOTIFY () {
2093
+ }
2094
+
2095
+ public HPOWERNOTIFY (Pointer pointer ) {
2096
+ super (pointer );
2097
+ }
2098
+ }
2099
+
2100
+ /**
2101
+ * Registers the application to receive power setting notifications for the specific power setting event.
2102
+ * @param hRecipient Handle indicating where the power setting notifications are to be sent.
2103
+ * For interactive applications, the Flags parameter should be DEVICE_NOTIFY_WINDOW_HANDLE,
2104
+ * and the hRecipient parameter should be a window handle.
2105
+ * For services, the Flags parameter should be DEVICE_NOTIFY_SERVICE_HANDLE, and the hRecipient
2106
+ * parameter should be a SERVICE_STATUS_HANDLE as returned from RegisterServiceCtrlHandlerEx.
2107
+ * @param PowerSettingGuid The GUID of the power setting for which notifications are to be sent.
2108
+ * @param Flags
2109
+ * <li>DEVICE_NOTIFY_WINDOW_HANDLE - Notifications are sent using WM_POWERBROADCAST messages
2110
+ * with a wParam parameter of PBT_POWERSETTINGCHANGE.
2111
+ * <li>DEVICE_NOTIFY_SERVICE_HANDLE - Notifications are sent to the HandlerEx callback function with a dwControl
2112
+ * parameter of SERVICE_CONTROL_POWEREVENT and a dwEventType of PBT_POWERSETTINGCHANGE.
2113
+ * @return a notification handle for unregistering for power notifications. If the function fails, the return
2114
+ * value is NULL. To get extended error information, call GetLastError.
2115
+ */
2116
+ HPOWERNOTIFY RegisterPowerSettingNotification (
2117
+ /*[in]*/ HANDLE hRecipient ,
2118
+ /*[in]*/ Guid .GUID PowerSettingGuid ,
2119
+ /*[in]*/ int Flags );
2120
+
2121
+ /**
2122
+ * Unregisters the power setting notification.
2123
+ * @param Handle The handle returned from the RegisterPowerSettingNotification function.
2124
+ * @return If the function succeeds, the return value is nonzero.
2125
+ * If the function fails, the return value is zero. To get extended error information, call GetLastError.
2126
+ */
2127
+ BOOL UnregisterPowerSettingNotification (
2128
+ /*[in]*/ HPOWERNOTIFY Handle
2129
+ );
2130
+
2131
+ int WM_POWERBROADCAST = 0x0218 ;
2132
+
2133
+ int PBT_APMQUERYSUSPEND = 0x0000 ;
2134
+ int PBT_APMQUERYSTANDBY = 0x0001 ;
2135
+ int PBT_APMQUERYSUSPENDFAILED = 0x0002 ;
2136
+ int PBT_APMQUERYSTANDBYFAILED = 0x0003 ;
2137
+ int PBT_APMSUSPEND = 0x0004 ;
2138
+ int PBT_APMSTANDBY = 0x0005 ;
2139
+ int PBT_APMRESUMECRITICAL = 0x0006 ;
2140
+ int PBT_APMRESUMESUSPEND = 0x0007 ;
2141
+ int PBT_APMRESUMESTANDBY = 0x0008 ;
2142
+ int PBT_APMBATTERYLOW = 0x0009 ;
2143
+ int PBT_APMPOWERSTATUSCHANGE = 0x000A ;
2144
+ int PBT_APMOEMEVENT = 0x000B ;
2145
+ int PBT_APMRESUMEAUTOMATIC = 0x0012 ;
2146
+ int PBT_POWERSETTINGCHANGE = 0x8013 ;
2147
+
2148
+ @ FieldOrder ({"PowerSetting" , "DataLength" , "Data" })
2149
+ class POWERBROADCAST_SETTING extends Structure {
2150
+ public Guid .GUID PowerSetting ;
2151
+ public int DataLength ;
2152
+ public byte Data [] = new byte [1 ];
2153
+
2154
+ public POWERBROADCAST_SETTING (Pointer p ) {
2155
+ super (p );
2156
+ read ();
2157
+ }
2158
+
2159
+ @ Override
2160
+ public final void read () {
2161
+ Data = new byte [getPointer ().getInt (fieldOffset ("DataLength" ))];
2162
+ super .read ();
2163
+ }
2164
+ }
2091
2165
}
0 commit comments