Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
7.6 KiB

  1. /*****************************************************************************\
  2. * *
  3. * powrprof.h - - Interface for powrprof.dll, the power policy applicator *
  4. * *
  5. * Version 1.0 *
  6. * *
  7. * Copyright (c) Microsoft Corporation. All rights reserved. *
  8. * *
  9. \*****************************************************************************/
  10. // Define the following to debug batmeter on machines with no battery support.
  11. //#define SIM_BATTERY 1
  12. #define CURRENT_REVISION 1
  13. #define STRSIZE(psz) ((lstrlen(psz) + 1) * sizeof(TCHAR))
  14. #define MAX_NAME_LEN 32 // Max length of name in characters.
  15. #define MAX_NAME_SIZE (MAX_NAME_LEN +1) * sizeof(TCHAR)
  16. #define MAX_DESC_LEN 512 // Max length of description in characters.
  17. #define MAX_DESC_SIZE (MAX_DESC_LEN +1) * sizeof(TCHAR)
  18. #define SEMAPHORE_TIMEOUT 10000
  19. #define NUM_DEC_DIGITS 10+1+1 // 10 digits + NUll and sign.
  20. #define SIZE_DEC_DIGITS (10+1+1) * sizeof(TCHAR)
  21. // Registry storage structures for the GLOBAL_POWER_POLICY data. There are two
  22. // structures, GLOBAL_MACHINE_POWER_POLICY and GLOBAL_USER_POWER_POLICY. the
  23. // GLOBAL_MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  24. // GLOBAL_USER_POWER_POLICY stores the per user data.
  25. typedef struct _GLOBAL_MACHINE_POWER_POLICY{
  26. ULONG Revision;
  27. SYSTEM_POWER_STATE LidOpenWakeAc;
  28. SYSTEM_POWER_STATE LidOpenWakeDc;
  29. ULONG BroadcastCapacityResolution;
  30. } GLOBAL_MACHINE_POWER_POLICY, *PGLOBAL_MACHINE_POWER_POLICY;
  31. typedef struct _GLOBAL_USER_POWER_POLICY{
  32. ULONG Revision;
  33. POWER_ACTION_POLICY PowerButtonAc;
  34. POWER_ACTION_POLICY PowerButtonDc;
  35. POWER_ACTION_POLICY SleepButtonAc;
  36. POWER_ACTION_POLICY SleepButtonDc;
  37. POWER_ACTION_POLICY LidCloseAc;
  38. POWER_ACTION_POLICY LidCloseDc;
  39. SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
  40. ULONG GlobalFlags;
  41. } GLOBAL_USER_POWER_POLICY, *PGLOBAL_USER_POWER_POLICY;
  42. // Structure to manage global power policies at the user level. This structure
  43. // contains data which is common across all power policy profiles.
  44. typedef struct _GLOBAL_POWER_POLICY{
  45. GLOBAL_USER_POWER_POLICY user;
  46. GLOBAL_MACHINE_POWER_POLICY mach;
  47. } GLOBAL_POWER_POLICY, *PGLOBAL_POWER_POLICY;
  48. // Registry storage structures for the POWER_POLICY data. There are three
  49. // structures, MACHINE_POWER_POLICY, MACHINE_PROCESSOR_POWER_POLICY and USER_POWER_POLICY. the
  50. // MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  51. // USER_POWER_POLICY stores the per user data.
  52. typedef struct _MACHINE_POWER_POLICY{
  53. ULONG Revision; // 1
  54. // meaning of power action "sleep"
  55. SYSTEM_POWER_STATE MinSleepAc;
  56. SYSTEM_POWER_STATE MinSleepDc;
  57. SYSTEM_POWER_STATE ReducedLatencySleepAc;
  58. SYSTEM_POWER_STATE ReducedLatencySleepDc;
  59. // parameters for dozing
  60. ULONG DozeTimeoutAc;
  61. ULONG DozeTimeoutDc;
  62. ULONG DozeS4TimeoutAc;
  63. ULONG DozeS4TimeoutDc;
  64. // processor policies
  65. UCHAR MinThrottleAc;
  66. UCHAR MinThrottleDc;
  67. UCHAR pad1[2];
  68. POWER_ACTION_POLICY OverThrottledAc;
  69. POWER_ACTION_POLICY OverThrottledDc;
  70. } MACHINE_POWER_POLICY, *PMACHINE_POWER_POLICY;
  71. typedef struct _MACHINE_PROCESSOR_POWER_POLICY {
  72. ULONG Revision; // 1
  73. PROCESSOR_POWER_POLICY ProcessorPolicyAc;
  74. PROCESSOR_POWER_POLICY ProcessorPolicyDc;
  75. } MACHINE_PROCESSOR_POWER_POLICY, *PMACHINE_PROCESSOR_POWER_POLICY;
  76. typedef struct _USER_POWER_POLICY{
  77. ULONG Revision; // 1
  78. // "system idle" detection
  79. POWER_ACTION_POLICY IdleAc;
  80. POWER_ACTION_POLICY IdleDc;
  81. ULONG IdleTimeoutAc;
  82. ULONG IdleTimeoutDc;
  83. UCHAR IdleSensitivityAc;
  84. UCHAR IdleSensitivityDc;
  85. // Throttling Policy
  86. UCHAR ThrottlePolicyAc;
  87. UCHAR ThrottlePolicyDc;
  88. // meaning of power action "sleep"
  89. SYSTEM_POWER_STATE MaxSleepAc;
  90. SYSTEM_POWER_STATE MaxSleepDc;
  91. // For future use
  92. ULONG Reserved[2];
  93. // video policies
  94. ULONG VideoTimeoutAc;
  95. ULONG VideoTimeoutDc;
  96. // hard disk policies
  97. ULONG SpindownTimeoutAc;
  98. ULONG SpindownTimeoutDc;
  99. // processor policies
  100. BOOLEAN OptimizeForPowerAc;
  101. BOOLEAN OptimizeForPowerDc;
  102. UCHAR FanThrottleToleranceAc;
  103. UCHAR FanThrottleToleranceDc;
  104. UCHAR ForcedThrottleAc;
  105. UCHAR ForcedThrottleDc;
  106. } USER_POWER_POLICY, *PUSER_POWER_POLICY;
  107. // Structure to manage power policies at the user level. This structure
  108. // contains data which is unique across power policy profiles.
  109. typedef struct _POWER_POLICY{
  110. USER_POWER_POLICY user;
  111. MACHINE_POWER_POLICY mach;
  112. } POWER_POLICY, *PPOWER_POLICY;
  113. // Constants for GlobalFlags
  114. #define EnableSysTrayBatteryMeter 0x01
  115. #define EnableMultiBatteryDisplay 0x02
  116. #define EnablePasswordLogon 0x04
  117. #define EnableWakeOnRing 0x08
  118. #define EnableVideoDimDisplay 0x10
  119. // This constant is passed as a uiID to WritePwrScheme.
  120. #define NEWSCHEME (UINT)-1
  121. // Prototype for EnumPwrSchemes callback proceedures.
  122. typedef BOOLEAN (CALLBACK* PWRSCHEMESENUMPROC)(UINT, DWORD, LPTSTR, DWORD, LPTSTR, PPOWER_POLICY, LPARAM);
  123. typedef BOOLEAN (CALLBACK* PFNNTINITIATEPWRACTION)(POWER_ACTION, SYSTEM_POWER_STATE, ULONG, BOOLEAN);
  124. // Public function prototypes
  125. BOOLEAN WINAPI GetPwrDiskSpindownRange(PUINT, PUINT);
  126. BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC, LPARAM);
  127. BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
  128. BOOLEAN WINAPI ReadPwrScheme(UINT, PPOWER_POLICY);
  129. BOOLEAN WINAPI WritePwrScheme(PUINT, LPTSTR, LPTSTR, PPOWER_POLICY);
  130. BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
  131. BOOLEAN WINAPI DeletePwrScheme(UINT);
  132. BOOLEAN WINAPI GetActivePwrScheme(PUINT);
  133. BOOLEAN WINAPI SetActivePwrScheme(UINT, PGLOBAL_POWER_POLICY, PPOWER_POLICY);
  134. BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES);
  135. BOOLEAN WINAPI IsPwrSuspendAllowed(VOID);
  136. BOOLEAN WINAPI IsPwrHibernateAllowed(VOID);
  137. BOOLEAN WINAPI IsPwrShutdownAllowed(VOID);
  138. BOOLEAN WINAPI IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY);
  139. BOOLEAN WINAPI SetSuspendState(BOOLEAN, BOOLEAN, BOOLEAN);
  140. BOOLEAN WINAPI GetCurrentPowerPolicies(PGLOBAL_POWER_POLICY, PPOWER_POLICY);
  141. BOOLEAN WINAPI CanUserWritePwrScheme(VOID);
  142. BOOLEAN WINAPI ReadProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
  143. BOOLEAN WINAPI WriteProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
  144. #ifndef NT_SUCCESS
  145. #define NTSTATUS LONG
  146. #define _OVERRIDE_NTSTATUS_
  147. #endif
  148. NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
  149. #ifdef _OVERRIDE_NTSTATUS_
  150. #undef NTSTATUS
  151. #endif
  152. void WINAPI LoadCurrentPwrScheme(HWND hwnd, HINSTANCE hAppInstance, LPSTR lpszCmdLine, int nCmdShow);
  153. void WINAPI MergeLegacyPwrScheme(HWND hwnd, HINSTANCE hAppInstance, LPSTR lpszCmdLine, int nCmdShow);