1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Stewart Gordon
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_powrprof.d)
9  */
10 module core.sys.windows.powrprof;
11 version (Windows):
12 pragma(lib, "powrprof");
13 
14 import core.sys.windows.windef;
15 import core.sys.windows.ntdef;
16 
17 // FIXME: look up Windows version support
18 
19 enum ULONG
20     EnableSysTrayBatteryMeter =  1,
21     EnableMultiBatteryDisplay =  2,
22     EnablePasswordLogon       =  4,
23     EnableWakeOnRing          =  8,
24     EnableVideoDimDisplay     = 16;
25 
26 enum UINT NEWSCHEME = -1;
27 
28 struct GLOBAL_MACHINE_POWER_POLICY {
29     ULONG              Revision;
30     SYSTEM_POWER_STATE LidOpenWakeAc;
31     SYSTEM_POWER_STATE LidOpenWakeDc;
32     ULONG              BroadcastCapacityResolution;
33 }
34 alias GLOBAL_MACHINE_POWER_POLICY* PGLOBAL_MACHINE_POWER_POLICY;
35 
36 struct GLOBAL_USER_POWER_POLICY {
37     ULONG               Revision;
38     POWER_ACTION_POLICY PowerButtonAc;
39     POWER_ACTION_POLICY PowerButtonDc;
40     POWER_ACTION_POLICY SleepButtonAc;
41     POWER_ACTION_POLICY SleepButtonDc;
42     POWER_ACTION_POLICY LidCloseAc;
43     POWER_ACTION_POLICY LidCloseDc;
44     SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] DischargePolicy;
45     ULONG GlobalFlags;
46 }
47 alias GLOBAL_USER_POWER_POLICY* PGLOBAL_USER_POWER_POLICY;
48 
49 struct GLOBAL_POWER_POLICY {
50     GLOBAL_USER_POWER_POLICY    user;
51     GLOBAL_MACHINE_POWER_POLICY mach;
52 }
53 alias GLOBAL_POWER_POLICY* PGLOBAL_POWER_POLICY;
54 
55 struct MACHINE_POWER_POLICY {
56     ULONG               Revision;
57     SYSTEM_POWER_STATE  MinSleepAc;
58     SYSTEM_POWER_STATE  MinSleepDc;
59     SYSTEM_POWER_STATE  ReducedLatencySleepAc;
60     SYSTEM_POWER_STATE  ReducedLatencySleepDc;
61     ULONG               DozeTimeoutAc;
62     ULONG               DozeTimeoutDc;
63     ULONG               DozeS4TimeoutAc;
64     ULONG               DozeS4TimeoutDc;
65     UCHAR               MinThrottleAc;
66     UCHAR               MinThrottleDc;
67     UCHAR[2]            pad1;
68     POWER_ACTION_POLICY OverThrottledAc;
69     POWER_ACTION_POLICY OverThrottledDc;
70 }
71 alias MACHINE_POWER_POLICY* PMACHINE_POWER_POLICY;
72 
73 struct MACHINE_PROCESSOR_POWER_POLICY {
74     ULONG Revision;
75     PROCESSOR_POWER_POLICY ProcessorPolicyAc;
76     PROCESSOR_POWER_POLICY ProcessorPolicyDc;
77 }
78 alias MACHINE_PROCESSOR_POWER_POLICY* PMACHINE_PROCESSOR_POWER_POLICY;
79 
80 struct USER_POWER_POLICY {
81    ULONG               Revision;
82    POWER_ACTION_POLICY IdleAc;
83    POWER_ACTION_POLICY IdleDc;
84    ULONG               IdleTimeoutAc;
85    ULONG               IdleTimeoutDc;
86    UCHAR               IdleSensitivityAc;
87    UCHAR               IdleSensitivityDc;
88    UCHAR               ThrottlePolicyAc;
89    UCHAR               ThrottlePolicyDc;
90    SYSTEM_POWER_STATE  MaxSleepAc;
91    SYSTEM_POWER_STATE  MaxSleepDc;
92    ULONG[2]            Reserved;
93    ULONG               VideoTimeoutAc;
94    ULONG               VideoTimeoutDc;
95    ULONG               SpindownTimeoutAc;
96    ULONG               SpindownTimeoutDc;
97    BOOLEAN             OptimizeForPowerAc;
98    BOOLEAN             OptimizeForPowerDc;
99    UCHAR               FanThrottleToleranceAc;
100    UCHAR               FanThrottleToleranceDc;
101    UCHAR               ForcedThrottleAc;
102    UCHAR               ForcedThrottleDc;
103 }
104 alias USER_POWER_POLICY* PUSER_POWER_POLICY;
105 
106 struct POWER_POLICY {
107     USER_POWER_POLICY    user;
108     MACHINE_POWER_POLICY mach;
109 }
110 alias POWER_POLICY* PPOWER_POLICY;
111 
112 extern (Windows) {
113     alias BOOLEAN function(UINT, DWORD, LPTSTR, DWORD, LPTSTR, PPOWER_POLICY,
114       LPARAM) PWRSCHEMESENUMPROC;
115     alias BOOLEAN function(POWER_ACTION, SYSTEM_POWER_STATE, ULONG, BOOLEAN)
116       PFNNTINITIATEPWRACTION;
117 
118     NTSTATUS CallNtPowerInformation(POWER_INFORMATION_LEVEL, PVOID, ULONG,
119       PVOID, ULONG);
120     BOOLEAN CanUserWritePwrScheme();
121     BOOLEAN DeletePwrScheme(UINT);
122     BOOLEAN EnumPwrSchemes(PWRSCHEMESENUMPROC, LPARAM);
123     BOOLEAN GetActivePwrScheme(PUINT);
124     BOOLEAN GetCurrentPowerPolicies(PGLOBAL_POWER_POLICY, PPOWER_POLICY);
125     BOOLEAN GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES);
126     BOOLEAN GetPwrDiskSpindownRange(PUINT, PUINT);
127     BOOLEAN IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY);
128     BOOLEAN IsPwrHibernateAllowed();
129     BOOLEAN IsPwrShutdownAllowed();
130     BOOLEAN IsPwrSuspendAllowed();
131     BOOLEAN ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
132     BOOLEAN ReadProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
133     BOOLEAN ReadPwrScheme(UINT, PPOWER_POLICY);
134     BOOLEAN SetActivePwrScheme(UINT, PGLOBAL_POWER_POLICY, PPOWER_POLICY);
135     BOOLEAN SetSuspendState(BOOLEAN, BOOLEAN, BOOLEAN);
136     BOOLEAN WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
137     BOOLEAN WriteProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
138     BOOLEAN ValidatePowerPolicies(PGLOBAL_POWER_POLICY, PPOWER_POLICY);
139     BOOLEAN WritePwrScheme(PUINT, LPTSTR, LPTSTR, PPOWER_POLICY);
140 }