jwapowrprof.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. // $Id: JwaPowrProf.pas,v 1.10 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaPowrProf;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "powrprof.h"'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows;
  52. // Registry storage structures for the GLOBAL_POWER_POLICY data. There are two
  53. // structures, GLOBAL_MACHINE_POWER_POLICY and GLOBAL_USER_POWER_POLICY. the
  54. // GLOBAL_MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  55. // GLOBAL_USER_POWER_POLICY stores the per user data.
  56. type
  57. PGLOBAL_MACHINE_POWER_POLICY = ^GLOBAL_MACHINE_POWER_POLICY;
  58. {$EXTERNALSYM PGLOBAL_MACHINE_POWER_POLICY}
  59. _GLOBAL_MACHINE_POWER_POLICY = record
  60. Revision: ULONG;
  61. LidOpenWakeAc: SYSTEM_POWER_STATE;
  62. LidOpenWakeDc: SYSTEM_POWER_STATE;
  63. BroadcastCapacityResolution: ULONG;
  64. end;
  65. {$EXTERNALSYM _GLOBAL_MACHINE_POWER_POLICY}
  66. GLOBAL_MACHINE_POWER_POLICY = _GLOBAL_MACHINE_POWER_POLICY;
  67. {$EXTERNALSYM GLOBAL_MACHINE_POWER_POLICY}
  68. TGlobalMachinePowerPolicy = GLOBAL_MACHINE_POWER_POLICY;
  69. PGlobalMachinePowerPolicy = PGLOBAL_MACHINE_POWER_POLICY;
  70. PGLOBAL_USER_POWER_POLICY = ^GLOBAL_USER_POWER_POLICY;
  71. {$EXTERNALSYM PGLOBAL_USER_POWER_POLICY}
  72. _GLOBAL_USER_POWER_POLICY = record
  73. Revision: ULONG;
  74. PowerButtonAc: POWER_ACTION_POLICY;
  75. PowerButtonDc: POWER_ACTION_POLICY;
  76. SleepButtonAc: POWER_ACTION_POLICY;
  77. SleepButtonDc: POWER_ACTION_POLICY;
  78. LidCloseAc: POWER_ACTION_POLICY;
  79. LidCloseDc: POWER_ACTION_POLICY;
  80. DischargePolicy: array [0..NUM_DISCHARGE_POLICIES - 1] of SYSTEM_POWER_LEVEL;
  81. GlobalFlags: ULONG;
  82. end;
  83. {$EXTERNALSYM _GLOBAL_USER_POWER_POLICY}
  84. GLOBAL_USER_POWER_POLICY = _GLOBAL_USER_POWER_POLICY;
  85. {$EXTERNALSYM GLOBAL_USER_POWER_POLICY}
  86. TGlobalUserPowerPolicy = GLOBAL_USER_POWER_POLICY;
  87. PGlobalUserPowerPolicy = PGLOBAL_USER_POWER_POLICY;
  88. // Structure to manage global power policies at the user level. This structure
  89. // contains data which is common across all power policy profiles.
  90. PGLOBAL_POWER_POLICY = ^GLOBAL_POWER_POLICY;
  91. {$EXTERNALSYM PGLOBAL_POWER_POLICY}
  92. _GLOBAL_POWER_POLICY = record
  93. user: GLOBAL_USER_POWER_POLICY;
  94. mach: GLOBAL_MACHINE_POWER_POLICY;
  95. end;
  96. {$EXTERNALSYM _GLOBAL_POWER_POLICY}
  97. GLOBAL_POWER_POLICY = _GLOBAL_POWER_POLICY;
  98. {$EXTERNALSYM GLOBAL_POWER_POLICY}
  99. TGlobalPowerPolicy = GLOBAL_POWER_POLICY;
  100. PGlobalPowerPolicy = PGLOBAL_POWER_POLICY;
  101. // Registry storage structures for the POWER_POLICY data. There are three
  102. // structures, MACHINE_POWER_POLICY, MACHINE_PROCESSOR_POWER_POLICY and USER_POWER_POLICY. the
  103. // MACHINE_POWER_POLICY stores per machine data for which there is no UI.
  104. // USER_POWER_POLICY stores the per user data.
  105. PMACHINE_POWER_POLICY = ^MACHINE_POWER_POLICY;
  106. {$EXTERNALSYM PMACHINE_POWER_POLICY}
  107. _MACHINE_POWER_POLICY = record
  108. Revision: ULONG; // 1
  109. // meaning of power action "sleep"
  110. MinSleepAc: SYSTEM_POWER_STATE;
  111. MinSleepDc: SYSTEM_POWER_STATE;
  112. ReducedLatencySleepAc: SYSTEM_POWER_STATE;
  113. ReducedLatencySleepDc: SYSTEM_POWER_STATE;
  114. // parameters for dozing
  115. DozeTimeoutAc: ULONG;
  116. DozeTimeoutDc: ULONG;
  117. DozeS4TimeoutAc: ULONG;
  118. DozeS4TimeoutDc: ULONG;
  119. // processor policies
  120. MinThrottleAc: UCHAR;
  121. MinThrottleDc: UCHAR;
  122. pad1: array [0..1] of UCHAR;
  123. OverThrottledAc: POWER_ACTION_POLICY;
  124. OverThrottledDc: POWER_ACTION_POLICY;
  125. end;
  126. {$EXTERNALSYM _MACHINE_POWER_POLICY}
  127. MACHINE_POWER_POLICY = _MACHINE_POWER_POLICY;
  128. {$EXTERNALSYM MACHINE_POWER_POLICY}
  129. TMachinePowerPolicy = MACHINE_POWER_POLICY;
  130. PMachinePowerPolicy = PMACHINE_POWER_POLICY;
  131. PMACHINE_PROCESSOR_POWER_POLICY = ^MACHINE_PROCESSOR_POWER_POLICY;
  132. {$EXTERNALSYM PMACHINE_PROCESSOR_POWER_POLICY}
  133. _MACHINE_PROCESSOR_POWER_POLICY = record
  134. Revision: ULONG; // 1
  135. ProcessorPolicyAc: PROCESSOR_POWER_POLICY;
  136. ProcessorPolicyDc: PROCESSOR_POWER_POLICY;
  137. end;
  138. {$EXTERNALSYM _MACHINE_PROCESSOR_POWER_POLICY}
  139. MACHINE_PROCESSOR_POWER_POLICY = _MACHINE_PROCESSOR_POWER_POLICY;
  140. {$EXTERNALSYM MACHINE_PROCESSOR_POWER_POLICY}
  141. TMachineProcessorPowerPolicy = MACHINE_PROCESSOR_POWER_POLICY;
  142. PMachineProcessorPowerPolicy = PMACHINE_PROCESSOR_POWER_POLICY;
  143. PUSER_POWER_POLICY = ^USER_POWER_POLICY;
  144. {$EXTERNALSYM PUSER_POWER_POLICY}
  145. _USER_POWER_POLICY = record
  146. Revision: ULONG; // 1
  147. // "system idle" detection
  148. IdleAc: POWER_ACTION_POLICY;
  149. IdleDc: POWER_ACTION_POLICY;
  150. IdleTimeoutAc: ULONG;
  151. IdleTimeoutDc: ULONG;
  152. IdleSensitivityAc: UCHAR;
  153. IdleSensitivityDc: UCHAR;
  154. // Throttling Policy
  155. ThrottlePolicyAc: UCHAR;
  156. ThrottlePolicyDc: UCHAR;
  157. // meaning of power action "sleep"
  158. MaxSleepAc: SYSTEM_POWER_STATE;
  159. MaxSleepDc: SYSTEM_POWER_STATE;
  160. // For future use
  161. Reserved: array [0..1] of ULONG;
  162. // video policies
  163. VideoTimeoutAc: ULONG;
  164. VideoTimeoutDc: ULONG;
  165. // hard disk policies
  166. SpindownTimeoutAc: ULONG;
  167. SpindownTimeoutDc: ULONG;
  168. // processor policies
  169. OptimizeForPowerAc: ByteBool;
  170. OptimizeForPowerDc: ByteBool;
  171. FanThrottleToleranceAc: UCHAR;
  172. FanThrottleToleranceDc: UCHAR;
  173. ForcedThrottleAc: UCHAR;
  174. ForcedThrottleDc: UCHAR;
  175. end;
  176. {$EXTERNALSYM _USER_POWER_POLICY}
  177. USER_POWER_POLICY = _USER_POWER_POLICY;
  178. {$EXTERNALSYM USER_POWER_POLICY}
  179. TUserPowerPolicy = USER_POWER_POLICY;
  180. PUserPowerPolicy = PUSER_POWER_POLICY;
  181. // Structure to manage power policies at the user level. This structure
  182. // contains data which is unique across power policy profiles.
  183. PPOWER_POLICY = ^POWER_POLICY;
  184. {$EXTERNALSYM PPOWER_POLICY}
  185. _POWER_POLICY = record
  186. user: USER_POWER_POLICY;
  187. mach: MACHINE_POWER_POLICY;
  188. end;
  189. {$EXTERNALSYM _POWER_POLICY}
  190. POWER_POLICY = _POWER_POLICY;
  191. {$EXTERNALSYM POWER_POLICY}
  192. TPowerPolicy = POWER_POLICY;
  193. PPowerPolicy = PPOWER_POLICY;
  194. // Constants for GlobalFlags
  195. const
  196. EnableSysTrayBatteryMeter = $01;
  197. {$EXTERNALSYM EnableSysTrayBatteryMeter}
  198. EnableMultiBatteryDisplay = $02;
  199. {$EXTERNALSYM EnableMultiBatteryDisplay}
  200. EnablePasswordLogon = $04;
  201. {$EXTERNALSYM EnablePasswordLogon}
  202. EnableWakeOnRing = $08;
  203. {$EXTERNALSYM EnableWakeOnRing}
  204. EnableVideoDimDisplay = $10;
  205. {$EXTERNALSYM EnableVideoDimDisplay}
  206. // This constant is passed as a uiID to WritePwrScheme.
  207. NEWSCHEME = UINT(-1);
  208. {$EXTERNALSYM NEWSCHEME}
  209. // Prototype for EnumPwrSchemes callback proceedures.
  210. type
  211. PWRSCHEMESENUMPROC = function(uiIndex: UINT; dwName: DWORD; sName: LPWSTR; dwDesc: DWORD; sDesc: LPWSTR; pp: PPOWER_POLICY; lParam: LPARAM): ByteBool; stdcall;
  212. {$EXTERNALSYM PWRSCHEMESENUMPROC}
  213. PFNNTINITIATEPWRACTION = function(pPowerAction: POWER_ACTION; SystemPowerState: SYSTEM_POWER_STATE; u: ULONG; b: ByteBool): ByteBool; stdcall;
  214. {$EXTERNALSYM PFNNTINITIATEPWRACTION}
  215. // Public function prototypes
  216. function GetPwrDiskSpindownRange(var RangeMax, RangeMin: UINT): ByteBool; stdcall;
  217. {$EXTERNALSYM GetPwrDiskSpindownRange}
  218. function EnumPwrSchemes(lpfnPwrSchemesEnumProc: PWRSCHEMESENUMPROC; lParam: LPARAM): ByteBool; stdcall;
  219. {$EXTERNALSYM EnumPwrSchemes}
  220. function ReadGlobalPwrPolicy(var pGlobalPowerPolicy: GLOBAL_POWER_POLICY): ByteBool; stdcall;
  221. {$EXTERNALSYM ReadGlobalPwrPolicy}
  222. function ReadPwrScheme(uiID: UINT; var pPowerPolicy: POWER_POLICY): ByteBool; stdcall;
  223. {$EXTERNALSYM ReadPwrScheme}
  224. function WritePwrScheme(puiID: PUINT; lpszName, lpszDescription: LPWSTR; const pPowerPolicy: POWER_POLICY): ByteBool; stdcall;
  225. {$EXTERNALSYM WritePwrScheme}
  226. function WriteGlobalPwrPolicy(const pGlobalPowerPolicy: GLOBAL_POWER_POLICY): ByteBool; stdcall;
  227. {$EXTERNALSYM WriteGlobalPwrPolicy}
  228. function DeletePwrScheme(uiIndex: UINT): ByteBool; stdcall;
  229. {$EXTERNALSYM DeletePwrScheme}
  230. function GetActivePwrScheme(var puiID: UINT): ByteBool; stdcall;
  231. {$EXTERNALSYM GetActivePwrScheme}
  232. function SetActivePwrScheme(uiID: UINT; pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): ByteBool; stdcall;
  233. {$EXTERNALSYM SetActivePwrScheme}
  234. function GetPwrCapabilities(var lpSystemPowerCapabilities: SYSTEM_POWER_CAPABILITIES): ByteBool; stdcall;
  235. {$EXTERNALSYM GetPwrCapabilities}
  236. function IsPwrSuspendAllowed: ByteBool; stdcall;
  237. {$EXTERNALSYM IsPwrSuspendAllowed}
  238. function IsPwrHibernateAllowed: ByteBool; stdcall;
  239. {$EXTERNALSYM IsPwrHibernateAllowed}
  240. function IsPwrShutdownAllowed: ByteBool; stdcall;
  241. {$EXTERNALSYM IsPwrShutdownAllowed}
  242. function IsAdminOverrideActive(pAdministratorPowerPolicy: PADMINISTRATOR_POWER_POLICY): ByteBool; stdcall;
  243. {$EXTERNALSYM IsAdminOverrideActive}
  244. function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: ByteBool): ByteBool; stdcall;
  245. {$EXTERNALSYM SetSuspendState}
  246. function GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): ByteBool; stdcall;
  247. {$EXTERNALSYM GetCurrentPowerPolicies}
  248. function CanUserWritePwrScheme: ByteBool; stdcall;
  249. {$EXTERNALSYM CanUserWritePwrScheme}
  250. function ReadProcessorPwrScheme(uiID: UINT; var pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): ByteBool; stdcall;
  251. {$EXTERNALSYM ReadProcessorPwrScheme}
  252. function WriteProcessorPwrScheme(uiID: UINT; const pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): ByteBool; stdcall;
  253. {$EXTERNALSYM WriteProcessorPwrScheme}
  254. function ValidatePowerPolicies(GlobalPolicy: PGLOBAL_POWER_POLICY; Policy: PPOWER_POLICY): ByteBool; stdcall;
  255. {$EXTERNALSYM ValidatePowerPolicies}
  256. function CallNtPowerInformation(InformationLeveL: POWER_INFORMATION_LEVEL; lpInputBuffer: PVOID; nInputBufferSize: ULONG; lpOutputBuffer: PVOID; nOutputBufferSize: ULONG): NTSTATUS; stdcall;
  257. {$EXTERNALSYM CallNtPowerInformation}
  258. implementation
  259. uses
  260. JwaWinDLLNames;
  261. {$IFDEF DYNAMIC_LINK}
  262. var
  263. _GetPwrDiskSpindownRange: Pointer;
  264. function GetPwrDiskSpindownRange;
  265. begin
  266. GetProcedureAddress(_GetPwrDiskSpindownRange, powrproflib, 'GetPwrDiskSpindownRange');
  267. asm
  268. MOV ESP, EBP
  269. POP EBP
  270. JMP [_GetPwrDiskSpindownRange]
  271. end;
  272. end;
  273. var
  274. _EnumPwrSchemes: Pointer;
  275. function EnumPwrSchemes;
  276. begin
  277. GetProcedureAddress(_EnumPwrSchemes, powrproflib, 'EnumPwrSchemes');
  278. asm
  279. MOV ESP, EBP
  280. POP EBP
  281. JMP [_EnumPwrSchemes]
  282. end;
  283. end;
  284. var
  285. _ReadGlobalPwrPolicy: Pointer;
  286. function ReadGlobalPwrPolicy;
  287. begin
  288. GetProcedureAddress(_ReadGlobalPwrPolicy, powrproflib, 'ReadGlobalPwrPolicy');
  289. asm
  290. MOV ESP, EBP
  291. POP EBP
  292. JMP [_ReadGlobalPwrPolicy]
  293. end;
  294. end;
  295. var
  296. _ReadPwrScheme: Pointer;
  297. function ReadPwrScheme;
  298. begin
  299. GetProcedureAddress(_ReadPwrScheme, powrproflib, 'ReadPwrScheme');
  300. asm
  301. MOV ESP, EBP
  302. POP EBP
  303. JMP [_ReadPwrScheme]
  304. end;
  305. end;
  306. var
  307. _WritePwrScheme: Pointer;
  308. function WritePwrScheme;
  309. begin
  310. GetProcedureAddress(_WritePwrScheme, powrproflib, 'WritePwrScheme');
  311. asm
  312. MOV ESP, EBP
  313. POP EBP
  314. JMP [_WritePwrScheme]
  315. end;
  316. end;
  317. var
  318. _WriteGlobalPwrPolicy: Pointer;
  319. function WriteGlobalPwrPolicy;
  320. begin
  321. GetProcedureAddress(_WriteGlobalPwrPolicy, powrproflib, 'WriteGlobalPwrPolicy');
  322. asm
  323. MOV ESP, EBP
  324. POP EBP
  325. JMP [_WriteGlobalPwrPolicy]
  326. end;
  327. end;
  328. var
  329. _DeletePwrScheme: Pointer;
  330. function DeletePwrScheme;
  331. begin
  332. GetProcedureAddress(_DeletePwrScheme, powrproflib, 'DeletePwrScheme');
  333. asm
  334. MOV ESP, EBP
  335. POP EBP
  336. JMP [_DeletePwrScheme]
  337. end;
  338. end;
  339. var
  340. _GetActivePwrScheme: Pointer;
  341. function GetActivePwrScheme;
  342. begin
  343. GetProcedureAddress(_GetActivePwrScheme, powrproflib, 'GetActivePwrScheme');
  344. asm
  345. MOV ESP, EBP
  346. POP EBP
  347. JMP [_GetActivePwrScheme]
  348. end;
  349. end;
  350. var
  351. _SetActivePwrScheme: Pointer;
  352. function SetActivePwrScheme;
  353. begin
  354. GetProcedureAddress(_SetActivePwrScheme, powrproflib, 'SetActivePwrScheme');
  355. asm
  356. MOV ESP, EBP
  357. POP EBP
  358. JMP [_SetActivePwrScheme]
  359. end;
  360. end;
  361. var
  362. _GetPwrCapabilities: Pointer;
  363. function GetPwrCapabilities;
  364. begin
  365. GetProcedureAddress(_GetPwrCapabilities, powrproflib, 'GetPwrCapabilities');
  366. asm
  367. MOV ESP, EBP
  368. POP EBP
  369. JMP [_GetPwrCapabilities]
  370. end;
  371. end;
  372. var
  373. _IsPwrSuspendAllowed: Pointer;
  374. function IsPwrSuspendAllowed;
  375. begin
  376. GetProcedureAddress(_IsPwrSuspendAllowed, powrproflib, 'IsPwrSuspendAllowed');
  377. asm
  378. MOV ESP, EBP
  379. POP EBP
  380. JMP [_IsPwrSuspendAllowed]
  381. end;
  382. end;
  383. var
  384. _IsPwrHibernateAllowed: Pointer;
  385. function IsPwrHibernateAllowed;
  386. begin
  387. GetProcedureAddress(_IsPwrHibernateAllowed, powrproflib, 'IsPwrHibernateAllowed');
  388. asm
  389. MOV ESP, EBP
  390. POP EBP
  391. JMP [_IsPwrHibernateAllowed]
  392. end;
  393. end;
  394. var
  395. _IsPwrShutdownAllowed: Pointer;
  396. function IsPwrShutdownAllowed;
  397. begin
  398. GetProcedureAddress(_IsPwrShutdownAllowed, powrproflib, 'IsPwrShutdownAllowed');
  399. asm
  400. MOV ESP, EBP
  401. POP EBP
  402. JMP [_IsPwrShutdownAllowed]
  403. end;
  404. end;
  405. var
  406. _IsAdminOverrideActive: Pointer;
  407. function IsAdminOverrideActive;
  408. begin
  409. GetProcedureAddress(_IsAdminOverrideActive, powrproflib, 'IsAdminOverrideActive');
  410. asm
  411. MOV ESP, EBP
  412. POP EBP
  413. JMP [_IsAdminOverrideActive]
  414. end;
  415. end;
  416. var
  417. _SetSuspendState: Pointer;
  418. function SetSuspendState;
  419. begin
  420. GetProcedureAddress(_SetSuspendState, powrproflib, 'SetSuspendState');
  421. asm
  422. MOV ESP, EBP
  423. POP EBP
  424. JMP [_SetSuspendState]
  425. end;
  426. end;
  427. var
  428. _GetCurrentPowerPolicies: Pointer;
  429. function GetCurrentPowerPolicies;
  430. begin
  431. GetProcedureAddress(_GetCurrentPowerPolicies, powrproflib, 'GetCurrentPowerPolicies');
  432. asm
  433. MOV ESP, EBP
  434. POP EBP
  435. JMP [_GetCurrentPowerPolicies]
  436. end;
  437. end;
  438. var
  439. _CanUserWritePwrScheme: Pointer;
  440. function CanUserWritePwrScheme;
  441. begin
  442. GetProcedureAddress(_CanUserWritePwrScheme, powrproflib, 'CanUserWritePwrScheme');
  443. asm
  444. MOV ESP, EBP
  445. POP EBP
  446. JMP [_CanUserWritePwrScheme]
  447. end;
  448. end;
  449. var
  450. _ReadProcessorPwrScheme: Pointer;
  451. function ReadProcessorPwrScheme;
  452. begin
  453. GetProcedureAddress(_ReadProcessorPwrScheme, powrproflib, 'ReadProcessorPwrScheme');
  454. asm
  455. MOV ESP, EBP
  456. POP EBP
  457. JMP [_ReadProcessorPwrScheme]
  458. end;
  459. end;
  460. var
  461. _WriteProcessorPwrScheme: Pointer;
  462. function WriteProcessorPwrScheme;
  463. begin
  464. GetProcedureAddress(_WriteProcessorPwrScheme, powrproflib, 'WriteProcessorPwrScheme');
  465. asm
  466. MOV ESP, EBP
  467. POP EBP
  468. JMP [_WriteProcessorPwrScheme]
  469. end;
  470. end;
  471. var
  472. _ValidatePowerPolicies: Pointer;
  473. function ValidatePowerPolicies;
  474. begin
  475. GetProcedureAddress(_ValidatePowerPolicies, powrproflib, 'ValidatePowerPolicies');
  476. asm
  477. MOV ESP, EBP
  478. POP EBP
  479. JMP [_ValidatePowerPolicies]
  480. end;
  481. end;
  482. var
  483. _CallNtPowerInformation: Pointer;
  484. function CallNtPowerInformation;
  485. begin
  486. GetProcedureAddress(_CallNtPowerInformation, powrproflib, 'CallNtPowerInformation');
  487. asm
  488. MOV ESP, EBP
  489. POP EBP
  490. JMP [_CallNtPowerInformation]
  491. end;
  492. end;
  493. {$ELSE}
  494. function GetPwrDiskSpindownRange; external powrproflib name 'GetPwrDiskSpindownRange';
  495. function EnumPwrSchemes; external powrproflib name 'EnumPwrSchemes';
  496. function ReadGlobalPwrPolicy; external powrproflib name 'ReadGlobalPwrPolicy';
  497. function ReadPwrScheme; external powrproflib name 'ReadPwrScheme';
  498. function WritePwrScheme; external powrproflib name 'WritePwrScheme';
  499. function WriteGlobalPwrPolicy; external powrproflib name 'WriteGlobalPwrPolicy';
  500. function DeletePwrScheme; external powrproflib name 'DeletePwrScheme';
  501. function GetActivePwrScheme; external powrproflib name 'GetActivePwrScheme';
  502. function SetActivePwrScheme; external powrproflib name 'SetActivePwrScheme';
  503. function GetPwrCapabilities; external powrproflib name 'GetPwrCapabilities';
  504. function IsPwrSuspendAllowed; external powrproflib name 'IsPwrSuspendAllowed';
  505. function IsPwrHibernateAllowed; external powrproflib name 'IsPwrHibernateAllowed';
  506. function IsPwrShutdownAllowed; external powrproflib name 'IsPwrShutdownAllowed';
  507. function IsAdminOverrideActive; external powrproflib name 'IsAdminOverrideActive';
  508. function SetSuspendState; external powrproflib name 'SetSuspendState';
  509. function GetCurrentPowerPolicies; external powrproflib name 'GetCurrentPowerPolicies';
  510. function CanUserWritePwrScheme; external powrproflib name 'CanUserWritePwrScheme';
  511. function ReadProcessorPwrScheme; external powrproflib name 'ReadProcessorPwrScheme';
  512. function WriteProcessorPwrScheme; external powrproflib name 'WriteProcessorPwrScheme';
  513. function ValidatePowerPolicies; external powrproflib name 'ValidatePowerPolicies';
  514. function CallNtPowerInformation; external powrproflib name 'CallNtPowerInformation';
  515. {$ENDIF DYNAMIC_LINK}
  516. end.