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