jwapowrprof.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. {******************************************************************************}
  2. { }
  3. { Power Policy Applicator interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: powrprof.h, released June 2000. The original Pascal }
  9. { code is: PowrProf.pas, released August 2001. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaPowrProf;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "powrprof.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinNT, JwaWinType;
  51. // Registry storage structures for the GLOBAL_POWER_POLICY data. There are two
  52. // structures, GLOBAL_MACHINE_POWER_POLICY and GLOBAL_USER_POWER_POLICY. the
  53. // GLOBAL_MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  54. // GLOBAL_USER_POWER_POLICY stores the per user data.
  55. type
  56. PGLOBAL_MACHINE_POWER_POLICY = ^GLOBAL_MACHINE_POWER_POLICY;
  57. {$EXTERNALSYM PGLOBAL_MACHINE_POWER_POLICY}
  58. _GLOBAL_MACHINE_POWER_POLICY = record
  59. Revision: ULONG;
  60. LidOpenWakeAc: SYSTEM_POWER_STATE;
  61. LidOpenWakeDc: SYSTEM_POWER_STATE;
  62. BroadcastCapacityResolution: ULONG;
  63. end;
  64. {$EXTERNALSYM _GLOBAL_MACHINE_POWER_POLICY}
  65. GLOBAL_MACHINE_POWER_POLICY = _GLOBAL_MACHINE_POWER_POLICY;
  66. {$EXTERNALSYM GLOBAL_MACHINE_POWER_POLICY}
  67. TGlobalMachinePowerPolicy = GLOBAL_MACHINE_POWER_POLICY;
  68. PGlobalMachinePowerPolicy = PGLOBAL_MACHINE_POWER_POLICY;
  69. PGLOBAL_USER_POWER_POLICY = ^GLOBAL_USER_POWER_POLICY;
  70. {$EXTERNALSYM PGLOBAL_USER_POWER_POLICY}
  71. _GLOBAL_USER_POWER_POLICY = record
  72. Revision: ULONG;
  73. PowerButtonAc: POWER_ACTION_POLICY;
  74. PowerButtonDc: POWER_ACTION_POLICY;
  75. SleepButtonAc: POWER_ACTION_POLICY;
  76. SleepButtonDc: POWER_ACTION_POLICY;
  77. LidCloseAc: POWER_ACTION_POLICY;
  78. LidCloseDc: POWER_ACTION_POLICY;
  79. DischargePolicy: array [0..NUM_DISCHARGE_POLICIES - 1] of SYSTEM_POWER_LEVEL;
  80. GlobalFlags: ULONG;
  81. end;
  82. {$EXTERNALSYM _GLOBAL_USER_POWER_POLICY}
  83. GLOBAL_USER_POWER_POLICY = _GLOBAL_USER_POWER_POLICY;
  84. {$EXTERNALSYM GLOBAL_USER_POWER_POLICY}
  85. TGlobalUserPowerPolicy = GLOBAL_USER_POWER_POLICY;
  86. PGlobalUserPowerPolicy = PGLOBAL_USER_POWER_POLICY;
  87. // Structure to manage global power policies at the user level. This structure
  88. // contains data which is common across all power policy profiles.
  89. PGLOBAL_POWER_POLICY = ^GLOBAL_POWER_POLICY;
  90. {$EXTERNALSYM PGLOBAL_POWER_POLICY}
  91. _GLOBAL_POWER_POLICY = record
  92. user: GLOBAL_USER_POWER_POLICY;
  93. mach: GLOBAL_MACHINE_POWER_POLICY;
  94. end;
  95. {$EXTERNALSYM _GLOBAL_POWER_POLICY}
  96. GLOBAL_POWER_POLICY = _GLOBAL_POWER_POLICY;
  97. {$EXTERNALSYM GLOBAL_POWER_POLICY}
  98. TGlobalPowerPolicy = GLOBAL_POWER_POLICY;
  99. PGlobalPowerPolicy = PGLOBAL_POWER_POLICY;
  100. // Registry storage structures for the POWER_POLICY data. There are three
  101. // structures, MACHINE_POWER_POLICY, MACHINE_PROCESSOR_POWER_POLICY and USER_POWER_POLICY. the
  102. // MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  103. // USER_POWER_POLICY stores the per user data.
  104. PMACHINE_POWER_POLICY = ^MACHINE_POWER_POLICY;
  105. {$EXTERNALSYM PMACHINE_POWER_POLICY}
  106. _MACHINE_POWER_POLICY = record
  107. Revision: ULONG; // 1
  108. // meaning of power action "sleep"
  109. MinSleepAc: SYSTEM_POWER_STATE;
  110. MinSleepDc: SYSTEM_POWER_STATE;
  111. ReducedLatencySleepAc: SYSTEM_POWER_STATE;
  112. ReducedLatencySleepDc: SYSTEM_POWER_STATE;
  113. // parameters for dozing
  114. DozeTimeoutAc: ULONG;
  115. DozeTimeoutDc: ULONG;
  116. DozeS4TimeoutAc: ULONG;
  117. DozeS4TimeoutDc: ULONG;
  118. // processor policies
  119. MinThrottleAc: UCHAR;
  120. MinThrottleDc: UCHAR;
  121. pad1: array [0..1] of UCHAR;
  122. OverThrottledAc: POWER_ACTION_POLICY;
  123. OverThrottledDc: POWER_ACTION_POLICY;
  124. end;
  125. {$EXTERNALSYM _MACHINE_POWER_POLICY}
  126. MACHINE_POWER_POLICY = _MACHINE_POWER_POLICY;
  127. {$EXTERNALSYM MACHINE_POWER_POLICY}
  128. TMachinePowerPolicy = MACHINE_POWER_POLICY;
  129. PMachinePowerPolicy = PMACHINE_POWER_POLICY;
  130. PMACHINE_PROCESSOR_POWER_POLICY = ^MACHINE_PROCESSOR_POWER_POLICY;
  131. {$EXTERNALSYM PMACHINE_PROCESSOR_POWER_POLICY}
  132. _MACHINE_PROCESSOR_POWER_POLICY = record
  133. Revision: ULONG; // 1
  134. ProcessorPolicyAc: PROCESSOR_POWER_POLICY;
  135. ProcessorPolicyDc: PROCESSOR_POWER_POLICY;
  136. end;
  137. {$EXTERNALSYM _MACHINE_PROCESSOR_POWER_POLICY}
  138. MACHINE_PROCESSOR_POWER_POLICY = _MACHINE_PROCESSOR_POWER_POLICY;
  139. {$EXTERNALSYM MACHINE_PROCESSOR_POWER_POLICY}
  140. TMachineProcessorPowerPolicy = MACHINE_PROCESSOR_POWER_POLICY;
  141. PMachineProcessorPowerPolicy = PMACHINE_PROCESSOR_POWER_POLICY;
  142. PUSER_POWER_POLICY = ^USER_POWER_POLICY;
  143. {$EXTERNALSYM PUSER_POWER_POLICY}
  144. _USER_POWER_POLICY = record
  145. Revision: ULONG; // 1
  146. // "system idle" detection
  147. IdleAc: POWER_ACTION_POLICY;
  148. IdleDc: POWER_ACTION_POLICY;
  149. IdleTimeoutAc: ULONG;
  150. IdleTimeoutDc: ULONG;
  151. IdleSensitivityAc: UCHAR;
  152. IdleSensitivityDc: UCHAR;
  153. // Throttling Policy
  154. ThrottlePolicyAc: UCHAR;
  155. ThrottlePolicyDc: UCHAR;
  156. // meaning of power action "sleep"
  157. MaxSleepAc: SYSTEM_POWER_STATE;
  158. MaxSleepDc: SYSTEM_POWER_STATE;
  159. // For future use
  160. Reserved: array [0..1] of ULONG;
  161. // video policies
  162. VideoTimeoutAc: ULONG;
  163. VideoTimeoutDc: ULONG;
  164. // hard disk policies
  165. SpindownTimeoutAc: ULONG;
  166. SpindownTimeoutDc: ULONG;
  167. // processor policies
  168. OptimizeForPowerAc: ByteBool;
  169. OptimizeForPowerDc: ByteBool;
  170. FanThrottleToleranceAc: UCHAR;
  171. FanThrottleToleranceDc: UCHAR;
  172. ForcedThrottleAc: UCHAR;
  173. ForcedThrottleDc: UCHAR;
  174. end;
  175. {$EXTERNALSYM _USER_POWER_POLICY}
  176. USER_POWER_POLICY = _USER_POWER_POLICY;
  177. {$EXTERNALSYM USER_POWER_POLICY}
  178. TUserPowerPolicy = USER_POWER_POLICY;
  179. PUserPowerPolicy = PUSER_POWER_POLICY;
  180. // Structure to manage power policies at the user level. This structure
  181. // contains data which is unique across power policy profiles.
  182. PPOWER_POLICY = ^POWER_POLICY;
  183. {$EXTERNALSYM PPOWER_POLICY}
  184. _POWER_POLICY = record
  185. user: USER_POWER_POLICY;
  186. mach: MACHINE_POWER_POLICY;
  187. end;
  188. {$EXTERNALSYM _POWER_POLICY}
  189. POWER_POLICY = _POWER_POLICY;
  190. {$EXTERNALSYM POWER_POLICY}
  191. TPowerPolicy = POWER_POLICY;
  192. PPowerPolicy = PPOWER_POLICY;
  193. // Constants for GlobalFlags
  194. const
  195. EnableSysTrayBatteryMeter = $01;
  196. {$EXTERNALSYM EnableSysTrayBatteryMeter}
  197. EnableMultiBatteryDisplay = $02;
  198. {$EXTERNALSYM EnableMultiBatteryDisplay}
  199. EnablePasswordLogon = $04;
  200. {$EXTERNALSYM EnablePasswordLogon}
  201. EnableWakeOnRing = $08;
  202. {$EXTERNALSYM EnableWakeOnRing}
  203. EnableVideoDimDisplay = $10;
  204. {$EXTERNALSYM EnableVideoDimDisplay}
  205. // This constant is passed as a uiID to WritePwrScheme.
  206. NEWSCHEME = UINT(-1);
  207. {$EXTERNALSYM NEWSCHEME}
  208. // Prototype for EnumPwrSchemes callback proceedures.
  209. type
  210. PWRSCHEMESENUMPROC = function(uiIndex: UINT; dwName: DWORD; sName: LPTSTR; dwDesc: DWORD; sDesc: LPTSTR; pp: PPOWER_POLICY; lParam: LPARAM): ByteBool; stdcall;
  211. {$EXTERNALSYM PWRSCHEMESENUMPROC}
  212. PFNNTINITIATEPWRACTION = function(pPowerAction: POWER_ACTION; SystemPowerState: SYSTEM_POWER_STATE; u: ULONG; b: ByteBool): ByteBool; stdcall;
  213. {$EXTERNALSYM PFNNTINITIATEPWRACTION}
  214. // Public function prototypes
  215. function GetPwrDiskSpindownRange(var RangeMax, RangeMin: UINT): ByteBool; stdcall;
  216. {$EXTERNALSYM GetPwrDiskSpindownRange}
  217. function EnumPwrSchemes(lpfnPwrSchemesEnumProc: PWRSCHEMESENUMPROC; lParam: LPARAM): ByteBool; stdcall;
  218. {$EXTERNALSYM EnumPwrSchemes}
  219. function ReadGlobalPwrPolicy(var pGlobalPowerPolicy: GLOBAL_POWER_POLICY): ByteBool; stdcall;
  220. {$EXTERNALSYM ReadGlobalPwrPolicy}
  221. function ReadPwrScheme(uiID: UINT; var pPowerPolicy: POWER_POLICY): ByteBool; stdcall;
  222. {$EXTERNALSYM ReadPwrScheme}
  223. function WritePwrScheme(puiID: PUINT; lpszName, lpszDescription: LPTSTR; const pPowerPolicy: POWER_POLICY): ByteBool; stdcall;
  224. {$EXTERNALSYM WritePwrScheme}
  225. function WriteGlobalPwrPolicy(const pGlobalPowerPolicy: GLOBAL_POWER_POLICY): ByteBool; stdcall;
  226. {$EXTERNALSYM WriteGlobalPwrPolicy}
  227. function DeletePwrScheme(uiIndex: UINT): ByteBool; stdcall;
  228. {$EXTERNALSYM DeletePwrScheme}
  229. function GetActivePwrScheme(var puiID: UINT): ByteBool; stdcall;
  230. {$EXTERNALSYM GetActivePwrScheme}
  231. function SetActivePwrScheme(uiID: UINT; pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): ByteBool; stdcall;
  232. {$EXTERNALSYM SetActivePwrScheme}
  233. function GetPwrCapabilities(var lpSystemPowerCapabilities: SYSTEM_POWER_CAPABILITIES): ByteBool; stdcall;
  234. {$EXTERNALSYM GetPwrCapabilities}
  235. function IsPwrSuspendAllowed: ByteBool; stdcall;
  236. {$EXTERNALSYM IsPwrSuspendAllowed}
  237. function IsPwrHibernateAllowed: ByteBool; stdcall;
  238. {$EXTERNALSYM IsPwrHibernateAllowed}
  239. function IsPwrShutdownAllowed: ByteBool; stdcall;
  240. {$EXTERNALSYM IsPwrShutdownAllowed}
  241. function IsAdminOverrideActive(pAdministratorPowerPolicy: PADMINISTRATOR_POWER_POLICY): ByteBool; stdcall;
  242. {$EXTERNALSYM IsAdminOverrideActive}
  243. function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: ByteBool): ByteBool; stdcall;
  244. {$EXTERNALSYM SetSuspendState}
  245. function GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): ByteBool; stdcall;
  246. {$EXTERNALSYM GetCurrentPowerPolicies}
  247. function CanUserWritePwrScheme: ByteBool; stdcall;
  248. {$EXTERNALSYM CanUserWritePwrScheme}
  249. function ReadProcessorPwrScheme(uiID: UINT; var pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): ByteBool; stdcall;
  250. {$EXTERNALSYM ReadProcessorPwrScheme}
  251. function WriteProcessorPwrScheme(uiID: UINT; const pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): ByteBool; stdcall;
  252. {$EXTERNALSYM WriteProcessorPwrScheme}
  253. function ValidatePowerPolicies(GlobalPolicy: PGLOBAL_POWER_POLICY; Policy: PPOWER_POLICY): ByteBool; stdcall;
  254. {$EXTERNALSYM ValidatePowerPolicies}
  255. function CallNtPowerInformation(InformationLeveL: POWER_INFORMATION_LEVEL; lpInputBuffer: PVOID; nInputBufferSize: ULONG; lpOutputBuffer: PVOID; nOutputBufferSize: ULONG): NTSTATUS; stdcall;
  256. {$EXTERNALSYM CallNtPowerInformation}
  257. implementation
  258. const
  259. powrproflib = 'powrprof.dll';
  260. {$IFDEF DYNAMIC_LINK}
  261. var
  262. _GetPwrDiskSpindownRange: Pointer;
  263. function GetPwrDiskSpindownRange;
  264. begin
  265. GetProcedureAddress(_GetPwrDiskSpindownRange, powrproflib, 'GetPwrDiskSpindownRange');
  266. asm
  267. MOV ESP, EBP
  268. POP EBP
  269. JMP [_GetPwrDiskSpindownRange]
  270. end;
  271. end;
  272. var
  273. _EnumPwrSchemes: Pointer;
  274. function EnumPwrSchemes;
  275. begin
  276. GetProcedureAddress(_EnumPwrSchemes, powrproflib, 'EnumPwrSchemes');
  277. asm
  278. MOV ESP, EBP
  279. POP EBP
  280. JMP [_EnumPwrSchemes]
  281. end;
  282. end;
  283. var
  284. _ReadGlobalPwrPolicy: Pointer;
  285. function ReadGlobalPwrPolicy;
  286. begin
  287. GetProcedureAddress(_ReadGlobalPwrPolicy, powrproflib, 'ReadGlobalPwrPolicy');
  288. asm
  289. MOV ESP, EBP
  290. POP EBP
  291. JMP [_ReadGlobalPwrPolicy]
  292. end;
  293. end;
  294. var
  295. _ReadPwrScheme: Pointer;
  296. function ReadPwrScheme;
  297. begin
  298. GetProcedureAddress(_ReadPwrScheme, powrproflib, 'ReadPwrScheme');
  299. asm
  300. MOV ESP, EBP
  301. POP EBP
  302. JMP [_ReadPwrScheme]
  303. end;
  304. end;
  305. var
  306. _WritePwrScheme: Pointer;
  307. function WritePwrScheme;
  308. begin
  309. GetProcedureAddress(_WritePwrScheme, powrproflib, 'WritePwrScheme');
  310. asm
  311. MOV ESP, EBP
  312. POP EBP
  313. JMP [_WritePwrScheme]
  314. end;
  315. end;
  316. var
  317. _WriteGlobalPwrPolicy: Pointer;
  318. function WriteGlobalPwrPolicy;
  319. begin
  320. GetProcedureAddress(_WriteGlobalPwrPolicy, powrproflib, 'WriteGlobalPwrPolicy');
  321. asm
  322. MOV ESP, EBP
  323. POP EBP
  324. JMP [_WriteGlobalPwrPolicy]
  325. end;
  326. end;
  327. var
  328. _DeletePwrScheme: Pointer;
  329. function DeletePwrScheme;
  330. begin
  331. GetProcedureAddress(_DeletePwrScheme, powrproflib, 'DeletePwrScheme');
  332. asm
  333. MOV ESP, EBP
  334. POP EBP
  335. JMP [_DeletePwrScheme]
  336. end;
  337. end;
  338. var
  339. _GetActivePwrScheme: Pointer;
  340. function GetActivePwrScheme;
  341. begin
  342. GetProcedureAddress(_GetActivePwrScheme, powrproflib, 'GetActivePwrScheme');
  343. asm
  344. MOV ESP, EBP
  345. POP EBP
  346. JMP [_GetActivePwrScheme]
  347. end;
  348. end;
  349. var
  350. _SetActivePwrScheme: Pointer;
  351. function SetActivePwrScheme;
  352. begin
  353. GetProcedureAddress(_SetActivePwrScheme, powrproflib, 'SetActivePwrScheme');
  354. asm
  355. MOV ESP, EBP
  356. POP EBP
  357. JMP [_SetActivePwrScheme]
  358. end;
  359. end;
  360. var
  361. _GetPwrCapabilities: Pointer;
  362. function GetPwrCapabilities;
  363. begin
  364. GetProcedureAddress(_GetPwrCapabilities, powrproflib, 'GetPwrCapabilities');
  365. asm
  366. MOV ESP, EBP
  367. POP EBP
  368. JMP [_GetPwrCapabilities]
  369. end;
  370. end;
  371. var
  372. _IsPwrSuspendAllowed: Pointer;
  373. function IsPwrSuspendAllowed;
  374. begin
  375. GetProcedureAddress(_IsPwrSuspendAllowed, powrproflib, 'IsPwrSuspendAllowed');
  376. asm
  377. MOV ESP, EBP
  378. POP EBP
  379. JMP [_IsPwrSuspendAllowed]
  380. end;
  381. end;
  382. var
  383. _IsPwrHibernateAllowed: Pointer;
  384. function IsPwrHibernateAllowed;
  385. begin
  386. GetProcedureAddress(_IsPwrHibernateAllowed, powrproflib, 'IsPwrHibernateAllowed');
  387. asm
  388. MOV ESP, EBP
  389. POP EBP
  390. JMP [_IsPwrHibernateAllowed]
  391. end;
  392. end;
  393. var
  394. _IsPwrShutdownAllowed: Pointer;
  395. function IsPwrShutdownAllowed;
  396. begin
  397. GetProcedureAddress(_IsPwrShutdownAllowed, powrproflib, 'IsPwrShutdownAllowed');
  398. asm
  399. MOV ESP, EBP
  400. POP EBP
  401. JMP [_IsPwrShutdownAllowed]
  402. end;
  403. end;
  404. var
  405. _IsAdminOverrideActive: Pointer;
  406. function IsAdminOverrideActive;
  407. begin
  408. GetProcedureAddress(_IsAdminOverrideActive, powrproflib, 'IsAdminOverrideActive');
  409. asm
  410. MOV ESP, EBP
  411. POP EBP
  412. JMP [_IsAdminOverrideActive]
  413. end;
  414. end;
  415. var
  416. _SetSuspendState: Pointer;
  417. function SetSuspendState;
  418. begin
  419. GetProcedureAddress(_SetSuspendState, powrproflib, 'SetSuspendState');
  420. asm
  421. MOV ESP, EBP
  422. POP EBP
  423. JMP [_SetSuspendState]
  424. end;
  425. end;
  426. var
  427. _GetCurrentPowerPolicies: Pointer;
  428. function GetCurrentPowerPolicies;
  429. begin
  430. GetProcedureAddress(_GetCurrentPowerPolicies, powrproflib, 'GetCurrentPowerPolicies');
  431. asm
  432. MOV ESP, EBP
  433. POP EBP
  434. JMP [_GetCurrentPowerPolicies]
  435. end;
  436. end;
  437. var
  438. _CanUserWritePwrScheme: Pointer;
  439. function CanUserWritePwrScheme;
  440. begin
  441. GetProcedureAddress(_CanUserWritePwrScheme, powrproflib, 'CanUserWritePwrScheme');
  442. asm
  443. MOV ESP, EBP
  444. POP EBP
  445. JMP [_CanUserWritePwrScheme]
  446. end;
  447. end;
  448. var
  449. _ReadProcessorPwrScheme: Pointer;
  450. function ReadProcessorPwrScheme;
  451. begin
  452. GetProcedureAddress(_ReadProcessorPwrScheme, powrproflib, 'ReadProcessorPwrScheme');
  453. asm
  454. MOV ESP, EBP
  455. POP EBP
  456. JMP [_ReadProcessorPwrScheme]
  457. end;
  458. end;
  459. var
  460. _WriteProcessorPwrScheme: Pointer;
  461. function WriteProcessorPwrScheme;
  462. begin
  463. GetProcedureAddress(_WriteProcessorPwrScheme, powrproflib, 'WriteProcessorPwrScheme');
  464. asm
  465. MOV ESP, EBP
  466. POP EBP
  467. JMP [_WriteProcessorPwrScheme]
  468. end;
  469. end;
  470. var
  471. _ValidatePowerPolicies: Pointer;
  472. function ValidatePowerPolicies;
  473. begin
  474. GetProcedureAddress(_ValidatePowerPolicies, powrproflib, 'ValidatePowerPolicies');
  475. asm
  476. MOV ESP, EBP
  477. POP EBP
  478. JMP [_ValidatePowerPolicies]
  479. end;
  480. end;
  481. var
  482. _CallNtPowerInformation: Pointer;
  483. function CallNtPowerInformation;
  484. begin
  485. GetProcedureAddress(_CallNtPowerInformation, powrproflib, 'CallNtPowerInformation');
  486. asm
  487. MOV ESP, EBP
  488. POP EBP
  489. JMP [_CallNtPowerInformation]
  490. end;
  491. end;
  492. {$ELSE}
  493. function GetPwrDiskSpindownRange; external powrproflib name 'GetPwrDiskSpindownRange';
  494. function EnumPwrSchemes; external powrproflib name 'EnumPwrSchemes';
  495. function ReadGlobalPwrPolicy; external powrproflib name 'ReadGlobalPwrPolicy';
  496. function ReadPwrScheme; external powrproflib name 'ReadPwrScheme';
  497. function WritePwrScheme; external powrproflib name 'WritePwrScheme';
  498. function WriteGlobalPwrPolicy; external powrproflib name 'WriteGlobalPwrPolicy';
  499. function DeletePwrScheme; external powrproflib name 'DeletePwrScheme';
  500. function GetActivePwrScheme; external powrproflib name 'GetActivePwrScheme';
  501. function SetActivePwrScheme; external powrproflib name 'SetActivePwrScheme';
  502. function GetPwrCapabilities; external powrproflib name 'GetPwrCapabilities';
  503. function IsPwrSuspendAllowed; external powrproflib name 'IsPwrSuspendAllowed';
  504. function IsPwrHibernateAllowed; external powrproflib name 'IsPwrHibernateAllowed';
  505. function IsPwrShutdownAllowed; external powrproflib name 'IsPwrShutdownAllowed';
  506. function IsAdminOverrideActive; external powrproflib name 'IsAdminOverrideActive';
  507. function SetSuspendState; external powrproflib name 'SetSuspendState';
  508. function GetCurrentPowerPolicies; external powrproflib name 'GetCurrentPowerPolicies';
  509. function CanUserWritePwrScheme; external powrproflib name 'CanUserWritePwrScheme';
  510. function ReadProcessorPwrScheme; external powrproflib name 'ReadProcessorPwrScheme';
  511. function WriteProcessorPwrScheme; external powrproflib name 'WriteProcessorPwrScheme';
  512. function ValidatePowerPolicies; external powrproflib name 'ValidatePowerPolicies';
  513. function CallNtPowerInformation; external powrproflib name 'CallNtPowerInformation';
  514. {$ENDIF DYNAMIC_LINK}
  515. end.