power.inc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2007 Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************
  10. Automatically converted by H2Pas 1.0.0 from power.h
  11. The following command line parameters were used:
  12. -d
  13. -c
  14. -w
  15. power.h
  16. }
  17. { Power Management APIs }
  18. {$ifdef read_interface}
  19. const
  20. AC_LINE_OFFLINE = $00;
  21. AC_LINE_ONLINE = $01;
  22. AC_LINE_BACKUP_POWER = $02;
  23. AC_LINE_UNKNOWN = $FF;
  24. BATTERY_FLAG_HIGH = $01;
  25. BATTERY_FLAG_LOW = $02;
  26. BATTERY_FLAG_CRITICAL = $04;
  27. BATTERY_FLAG_CHARGING = $08;
  28. BATTERY_FLAG_NO_BATTERY = $80;
  29. BATTERY_FLAG_UNKNOWN = $FF;
  30. BATTERY_PERCENTAGE_UNKNOWN = $FF;
  31. BATTERY_LIFE_UNKNOWN = $FFFFFFFF;
  32. type
  33. _SYSTEM_POWER_STATUS_EX = record
  34. ACLineStatus : BYTE;
  35. BatteryFlag : BYTE;
  36. BatteryLifePercent : BYTE;
  37. Reserved1 : BYTE;
  38. BatteryLifeTime : DWORD;
  39. BatteryFullLifeTime : DWORD;
  40. Reserved2 : BYTE;
  41. BackupBatteryFlag : BYTE;
  42. BackupBatteryLifePercent : BYTE;
  43. Reserved3 : BYTE;
  44. BackupBatteryLifeTime : DWORD;
  45. BackupBatteryFullLifeTime : DWORD;
  46. end;
  47. SYSTEM_POWER_STATUS_EX = _SYSTEM_POWER_STATUS_EX;
  48. PSYSTEM_POWER_STATUS_EX = ^_SYSTEM_POWER_STATUS_EX;
  49. LPSYSTEM_POWER_STATUS_EX = ^_SYSTEM_POWER_STATUS_EX;
  50. {
  51. @struct SYSTEM_POWER_STATUS_EX2 | contains information about the power status
  52. of the system.
  53. @field BYTE | ACLineStatus | AC power status. Must be one of
  54. AC_LINE_OFFLINE, AC_LINE_ONLINE, AC_LINE_BACKUP_POWER, or AC_LINE_UNKNOWN.
  55. @field BYTE | BatteryFlag | Battery charge status. Must be one of
  56. BATTERY_FLAG_HIGH, BATTERY_FLAG_LOW, BATTERY_FLAG_CRITICAL,
  57. BATTERY_FLAG_CHARGING, BATTERY_FLAG_NO_BATTERY, or BATTERY_FLAG_UNKNOWN
  58. @field BYTE | BatteryLifePercent | Percentage of full battery charge
  59. remaining. Must be in the range 0 to 100, or BATTERY_PERCENTAGE_UNKNOWN.
  60. @field BYTE | Reserved1 | Must be zero.
  61. @field DWORD | BatteryLifeTime | Number of seconds of battery life
  62. remaining, or BATTERY_LIFE_UNKNOWN if remaining seconds are unknown.
  63. @field DWORD | BatteryFullLifeTime | Number of seconds of battery life when
  64. at full charge, or BATTERY_LIFE_UNKNOWN if full lifetime is unknown.
  65. @field BYTE | Reserved2 | Must be zero.
  66. @field BYTE | BackupBatteryFlag | Backup battery charge status. Must be one
  67. of BATTERY_FLAG_HIGH, BATTERY_FLAG_LOW, BATTERY_FLAG_CRITICAL,
  68. BATTERY_FLAG_CHARGING, BATTERY_FLAG_NO_BATTERY, or BATTERY_FLAG_UNKNOWN.
  69. @field BYTE | BackupBatteryLifePercent | Percentage of full backup battery
  70. charge remaining. Must be in the range 0 to 100, or
  71. BATTERY_PERCENTAGE_UNKNOWN.
  72. @field BYTE | Reserved3 | Must be zero.
  73. @field DWORD | BackupBatteryLifeTime | Number of seconds of backup battery
  74. life remaining, or BATTERY_LIFE_UNKNOWN if remaining seconds are unknown.
  75. @field DWORD | BackupBatteryFullLifeTime | Number of seconds of backup
  76. battery life when at full charge, or BATTERY_LIFE_UNKNOWN if full lifetime
  77. is unknown.
  78. }
  79. const
  80. BATTERY_CHEMISTRY_ALKALINE = $01;
  81. BATTERY_CHEMISTRY_NICD = $02;
  82. BATTERY_CHEMISTRY_NIMH = $03;
  83. BATTERY_CHEMISTRY_LION = $04;
  84. BATTERY_CHEMISTRY_LIPOLY = $05;
  85. BATTERY_CHEMISTRY_ZINCAIR = $06;
  86. BATTERY_CHEMISTRY_UNKNOWN = $FF;
  87. { Above here is old struct, below are new fields }
  88. { Reports Reading of battery voltage in millivolts (0..65535 mV) }
  89. { Reports Instantaneous current drain (mA). 0..32767 for charge, 0 to -32768 for discharge }
  90. { Reports short term average of device current drain (mA). 0..32767 for charge, 0 to -32768 for discharge }
  91. { Reports time constant (mS) of integration used in reporting BatteryAverageCurrent }
  92. { Reports long-term cumulative average DISCHARGE (mAH). Reset by charging or changing the batteries. 0 to 32767 mAH }
  93. { Reports Battery temp in 0.1 degree C (-3276.8 to 3276.7 degrees C) }
  94. { Reports Reading of backup battery voltage }
  95. { See Chemistry defines above }
  96. { New fields can be added below, but don't change any existing ones }
  97. type
  98. _SYSTEM_POWER_STATUS_EX2 = record
  99. ACLineStatus : BYTE;
  100. BatteryFlag : BYTE;
  101. BatteryLifePercent : BYTE;
  102. Reserved1 : BYTE;
  103. BatteryLifeTime : DWORD;
  104. BatteryFullLifeTime : DWORD;
  105. Reserved2 : BYTE;
  106. BackupBatteryFlag : BYTE;
  107. BackupBatteryLifePercent : BYTE;
  108. Reserved3 : BYTE;
  109. BackupBatteryLifeTime : DWORD;
  110. BackupBatteryFullLifeTime : DWORD;
  111. BatteryVoltage : DWORD;
  112. BatteryCurrent : DWORD;
  113. BatteryAverageCurrent : DWORD;
  114. BatteryAverageInterval : DWORD;
  115. BatterymAHourConsumed : DWORD;
  116. BatteryTemperature : DWORD;
  117. BackupBatteryVoltage : DWORD;
  118. BatteryChemistry : BYTE;
  119. end;
  120. SYSTEM_POWER_STATUS_EX2 = _SYSTEM_POWER_STATUS_EX2;
  121. PSYSTEM_POWER_STATUS_EX2 = ^_SYSTEM_POWER_STATUS_EX2;
  122. LPSYSTEM_POWER_STATUS_EX2 = ^_SYSTEM_POWER_STATUS_EX2;
  123. { @CESYSGEN IF COREDLL_BATTERY }
  124. function GetSystemPowerStatusEx(var SystemPowerStatusEx: SYSTEM_POWER_STATUS_EX; fUpdate:BOOL):BOOL;external KernelDLL name 'GetSystemPowerStatusEx';
  125. { Return value : 0 = fail. Non-zero indicates length of returned data. }
  126. function GetSystemPowerStatusEx2(var SystemPowerStatusEx2: SYSTEM_POWER_STATUS_EX2; dwLen:DWORD; fUpdate:BOOL):DWORD;external KernelDLL name 'GetSystemPowerStatusEx2';
  127. {$endif read_interface}