Leaked source code of windows server 2003
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.

218 lines
6.4 KiB

  1. #ifndef __POWERCFG_H
  2. #define __POWERCFG_H
  3. #ifdef __cplusplus
  4. extern "C" { /* Assume C declarations for C++ */
  5. #endif /* __cplusplus */
  6. /*++
  7. Copyright (c) 2001 Microsoft Corporation
  8. Module Name:
  9. powercfg.h
  10. Abstract:
  11. Allows users to view and modify power schemes and system power settings
  12. from the command line. May be useful in unattended configuration and
  13. for headless systems.
  14. Author:
  15. Ben Hertzberg (t-benher) 1-Jun-2001
  16. Revision History:
  17. Ben Hertzberg (t-benher) 4-Jun-2001 - import/export added
  18. Ben Hertzberg (t-benher) 1-Jun-2001 - created it.
  19. --*/
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #include <windows.h>
  24. #include <tchar.h>
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <powrprof.h>
  28. #include <mstask.h>
  29. // main options
  30. #define CMDOPTION_LIST _T( "l|list" )
  31. #define CMDOPTION_QUERY _T( "q|query" )
  32. #define CMDOPTION_CREATE _T( "c|create" )
  33. #define CMDOPTION_DELETE _T( "d|delete" )
  34. #define CMDOPTION_SETACTIVE _T( "s|setactive" )
  35. #define CMDOPTION_CHANGE _T( "x|change" )
  36. #define CMDOPTION_HIBERNATE _T( "h|hibernate" )
  37. #define CMDOPTION_EXPORT _T( "e|export" )
  38. #define CMDOPTION_IMPORT _T( "i|import" )
  39. #define CMDOPTION_GLOBALFLAG _T( "g|globalpowerflag" )
  40. #define CMDOPTION_SSTATES _T( "a|availablesleepstates" )
  41. #define CMDOPTION_BATTERYALARM _T( "b|batteryalarm" )
  42. #define CMDOPTION_USAGE _T( "?|help" )
  43. // 'numerical' sub-option for query, create, delete, setactive, change, export, import
  44. #define CMDOPTION_NUMERICAL _T( "n|numerical" )
  45. // 'change' sub-options
  46. #define CMDOPTION_MONITOR_OFF_AC _T( "monitor-timeout-ac" )
  47. #define CMDOPTION_MONITOR_OFF_DC _T( "monitor-timeout-dc" )
  48. #define CMDOPTION_DISK_OFF_AC _T( "disk-timeout-ac" )
  49. #define CMDOPTION_DISK_OFF_DC _T( "disk-timeout-dc" )
  50. #define CMDOPTION_STANDBY_AC _T( "standby-timeout-ac" )
  51. #define CMDOPTION_STANDBY_DC _T( "standby-timeout-dc" )
  52. #define CMDOPTION_HIBER_AC _T( "hibernate-timeout-ac" )
  53. #define CMDOPTION_HIBER_DC _T( "hibernate-timeout-dc" )
  54. #define CMDOPTION_THROTTLE_AC _T( "processor-throttle-ac" )
  55. #define CMDOPTION_THROTTLE_DC _T( "processor-throttle-dc" )
  56. // 'import' / 'export' sub-options
  57. #define CMDOPTION_FILE _T( "f|file" )
  58. // globalpowerflag sub-options
  59. #define CMDOPTION_POWEROPTION _T( "option" )
  60. #define CMDOPTION_BATTERYICON _T( "batteryicon" )
  61. #define CMDOPTION_MULTIBATTERY _T( "multibattery" )
  62. #define CMDOPTION_RESUMEPASSWORD _T( "resumepassword" )
  63. #define CMDOPTION_WAKEONRING _T( "wakeonring" )
  64. #define CMDOPTION_VIDEODIM _T( "videodim" )
  65. // lowbattery and criticalbattery sub-options
  66. #define CMDOPTION_ALARMACTIVE _T( "activate" )
  67. #define CMDOPTION_ALARMLEVEL _T( "level" )
  68. #define CMDOPTION_ALARMTEXT _T( "text" )
  69. #define CMDOPTION_ALARMSOUND _T( "sound" )
  70. #define CMDOPTION_ALARMACTION _T( "action" )
  71. #define CMDOPTION_ALARMFORCE _T( "forceaction" )
  72. #define CMDOPTION_ALARMPROGRAM _T( "program" )
  73. // main option indicies
  74. #define CMDINDEX_LIST 0
  75. #define CMDINDEX_QUERY 1
  76. #define CMDINDEX_CREATE 2
  77. #define CMDINDEX_DELETE 3
  78. #define CMDINDEX_SETACTIVE 4
  79. #define CMDINDEX_CHANGE 5
  80. #define CMDINDEX_HIBERNATE 6
  81. #define CMDINDEX_EXPORT 7
  82. #define CMDINDEX_IMPORT 8
  83. #define CMDINDEX_GLOBALFLAG 9
  84. #define CMDINDEX_SSTATES 10
  85. #define CMDINDEX_BATTERYALARM 11
  86. #define CMDINDEX_USAGE 12
  87. #define NUM_MAIN_CMDS 13 // max(main option CMDINDEX_xxx) + 1
  88. #define CMDINDEX_NUMERICAL 13
  89. // sub-option indices
  90. #define CMDINDEX_MONITOR_OFF_AC 14
  91. #define CMDINDEX_MONITOR_OFF_DC 15
  92. #define CMDINDEX_DISK_OFF_AC 16
  93. #define CMDINDEX_DISK_OFF_DC 17
  94. #define CMDINDEX_STANDBY_AC 18
  95. #define CMDINDEX_STANDBY_DC 19
  96. #define CMDINDEX_HIBER_AC 20
  97. #define CMDINDEX_HIBER_DC 21
  98. #define CMDINDEX_THROTTLE_AC 22
  99. #define CMDINDEX_THROTTLE_DC 23
  100. #define CMDINDEX_FILE 24
  101. #define CMDINDEX_POWEROPTION 25
  102. #define CMDINDEX_ALARMACTIVE 26
  103. #define CMDINDEX_ALARMLEVEL 27
  104. #define CMDINDEX_ALARMTEXT 28
  105. #define CMDINDEX_ALARMSOUND 29
  106. #define CMDINDEX_ALARMACTION 30
  107. #define CMDINDEX_ALARMFORCE 31
  108. #define CMDINDEX_ALARMPROGRAM 32
  109. #define NUM_CMDS 33 // max(any CMDINDEX_xxx) + 1
  110. // Other constants
  111. // Exit values
  112. #define EXIT_SUCCESS 0
  113. #define EXIT_FAILURE 1
  114. #ifdef __cplusplus
  115. class
  116. PowerLoggingMessage
  117. {
  118. protected: // data
  119. DWORD _MessageResourceId;
  120. PSYSTEM_POWER_STATE_DISABLE_REASON _LoggingReason;
  121. PWSTR _MessageResourceString;
  122. HINSTANCE _hInst;
  123. public: // methods
  124. PowerLoggingMessage(
  125. IN PSYSTEM_POWER_STATE_DISABLE_REASON LoggingReason,
  126. IN DWORD SStateBaseMessageIndex,
  127. IN HINSTANCE hInstance
  128. );
  129. virtual ~PowerLoggingMessage(VOID);
  130. virtual BOOL GetString(PWSTR *String) = 0;
  131. protected:
  132. PWSTR
  133. DuplicateString(
  134. IN PWSTR String
  135. );
  136. BOOL
  137. GetResourceString(
  138. OUT PWSTR *String
  139. );
  140. };
  141. class
  142. NoSubstitutionPowerLoggingMessage :
  143. public PowerLoggingMessage
  144. {
  145. public:
  146. NoSubstitutionPowerLoggingMessage(
  147. IN PSYSTEM_POWER_STATE_DISABLE_REASON LoggingReason,
  148. IN DWORD SStateBaseMessageIndex,
  149. IN HINSTANCE hInstance
  150. );
  151. BOOL GetString(PWSTR *String);
  152. };
  153. class
  154. SubstituteNtStatusPowerLoggingMessage :
  155. public PowerLoggingMessage
  156. {
  157. public:
  158. SubstituteNtStatusPowerLoggingMessage(
  159. IN PSYSTEM_POWER_STATE_DISABLE_REASON LoggingReason,
  160. IN DWORD SStateBaseMessageIndex,
  161. IN HINSTANCE hInstance
  162. );
  163. BOOL GetString(PWSTR *String);
  164. };
  165. class
  166. SubstituteMultiSzPowerLoggingMessage :
  167. public PowerLoggingMessage
  168. {
  169. public:
  170. SubstituteMultiSzPowerLoggingMessage(
  171. IN PSYSTEM_POWER_STATE_DISABLE_REASON LoggingReason,
  172. IN DWORD SStateBaseMessageIndex,
  173. IN HINSTANCE hInstance
  174. );
  175. BOOL GetString(PWSTR *String);
  176. };
  177. }
  178. #endif /* __cplusplus */
  179. #endif