JwaPowrProf.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:21k
源码类别:

Windows编程

开发平台:

Delphi

  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@chello.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 home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaPowrProf;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "powrprof.h"'}
  47. {$HPPEMIT ''}
  48. {$I WINDEFINES.INC}
  49. interface
  50. uses
  51.   JwaWinNT, JwaWinType;
  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: BOOLEAN;
  170.     OptimizeForPowerDc: BOOLEAN;
  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. // TODO REPLACE BOOLEAN WITH ...
  211. type
  212.   PWRSCHEMESENUMPROC = function (uiIndex: UINT; dwName: DWORD; sName: LPTSTR; dwDesc: DWORD; sDesc: LPTSTR; pp: PPOWER_POLICY; lParam: LPARAM): BOOLEAN; stdcall;
  213.   {$EXTERNALSYM PWRSCHEMESENUMPROC}
  214.   PFNNTINITIATEPWRACTION = function (pPowerAction: POWER_ACTION; SystemPowerState: SYSTEM_POWER_STATE; u: ULONG; b: BOOLEAN): BOOLEAN; stdcall;
  215.   {$EXTERNALSYM PFNNTINITIATEPWRACTION}
  216. // Public function prototypes
  217. function GetPwrDiskSpindownRange(var RangeMax, RangeMin: UINT): BOOLEAN; stdcall;
  218. {$EXTERNALSYM GetPwrDiskSpindownRange}
  219. function EnumPwrSchemes(lpfnPwrSchemesEnumProc: PWRSCHEMESENUMPROC; lParam: LPARAM): BOOLEAN; stdcall;
  220. {$EXTERNALSYM EnumPwrSchemes}
  221. function ReadGlobalPwrPolicy(var pGlobalPowerPolicy: GLOBAL_POWER_POLICY): BOOLEAN; stdcall;
  222. {$EXTERNALSYM ReadGlobalPwrPolicy}
  223. function ReadPwrScheme(uiID: UINT; var pPowerPolicy: POWER_POLICY): BOOLEAN; stdcall;
  224. {$EXTERNALSYM ReadPwrScheme}
  225. function WritePwrScheme(puiID: PUINT; lpszName, lpszDescription: LPTSTR; const pPowerPolicy: POWER_POLICY): BOOLEAN; stdcall;
  226. {$EXTERNALSYM WritePwrScheme}
  227. function WriteGlobalPwrPolicy(const pGlobalPowerPolicy: GLOBAL_POWER_POLICY): BOOLEAN; stdcall;
  228. {$EXTERNALSYM WriteGlobalPwrPolicy}
  229. function DeletePwrScheme(uiIndex: UINT): BOOLEAN; stdcall;
  230. {$EXTERNALSYM DeletePwrScheme}
  231. function GetActivePwrScheme(var puiID: UINT): BOOLEAN; stdcall;
  232. {$EXTERNALSYM GetActivePwrScheme}
  233. function SetActivePwrScheme(uiID: UINT; pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): BOOLEAN; stdcall;
  234. {$EXTERNALSYM SetActivePwrScheme}
  235. function GetPwrCapabilities(var lpSystemPowerCapabilities: SYSTEM_POWER_CAPABILITIES): BOOLEAN; stdcall;
  236. {$EXTERNALSYM GetPwrCapabilities}
  237. function IsPwrSuspendAllowed: BOOLEAN; stdcall;
  238. {$EXTERNALSYM IsPwrSuspendAllowed}
  239. function IsPwrHibernateAllowed: BOOLEAN; stdcall;
  240. {$EXTERNALSYM IsPwrHibernateAllowed}
  241. function IsPwrShutdownAllowed: BOOLEAN; stdcall;
  242. {$EXTERNALSYM IsPwrShutdownAllowed}
  243. function IsAdminOverrideActive(pAdministratorPowerPolicy: PADMINISTRATOR_POWER_POLICY): BOOLEAN; stdcall;
  244. {$EXTERNALSYM IsAdminOverrideActive}
  245. function SetSuspendState(Hibernate, ForceCritical, DisableWakeEvent: BOOLEAN): BOOLEAN; stdcall;
  246. {$EXTERNALSYM SetSuspendState}
  247. function GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): BOOLEAN; stdcall;
  248. {$EXTERNALSYM GetCurrentPowerPolicies}
  249. function CanUserWritePwrScheme: BOOLEAN; stdcall;
  250. {$EXTERNALSYM CanUserWritePwrScheme}
  251. function ReadProcessorPwrScheme(uiID: UINT; var pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): BOOLEAN; stdcall;
  252. {$EXTERNALSYM ReadProcessorPwrScheme}
  253. function WriteProcessorPwrScheme(uiID: UINT; const pMachineProcessorPowerPolicy: MACHINE_PROCESSOR_POWER_POLICY): BOOLEAN; stdcall;
  254. {$EXTERNALSYM WriteProcessorPwrScheme}
  255. function ValidatePowerPolicies(GlobalPolicy: PGLOBAL_POWER_POLICY; Policy: PPOWER_POLICY): BOOLEAN; stdcall;
  256. {$EXTERNALSYM ValidatePowerPolicies}
  257. function CallNtPowerInformation(InformationLeveL: POWER_INFORMATION_LEVEL; lpInputBuffer: PVOID; nInputBufferSize: ULONG; lpOutputBuffer: PVOID; nOutputBufferSize: ULONG): NTSTATUS; stdcall;
  258. {$EXTERNALSYM CallNtPowerInformation}
  259. implementation
  260. uses
  261.   SysUtils;
  262. const
  263.   powrprof_lib = 'powrprof.dll';
  264. {$IFDEF DYNAMIC_LINK}
  265. var
  266.   _GetPwrDiskSpindownRange: Pointer;
  267. function GetPwrDiskSpindownRange;
  268. begin
  269.   GetProcedureAddress(_GetPwrDiskSpindownRange, powrprof_lib, 'GetPwrDiskSpindownRange');
  270.   asm
  271.     mov esp, ebp
  272.     pop ebp
  273.     jmp [_GetPwrDiskSpindownRange]
  274.   end;
  275. end;
  276. {$ELSE}
  277. function GetPwrDiskSpindownRange; external powrprof_lib name 'GetPwrDiskSpindownRange';
  278. {$ENDIF DYNAMIC_LINK}
  279. {$IFDEF DYNAMIC_LINK}
  280. var
  281.   _EnumPwrSchemes: Pointer;
  282. function EnumPwrSchemes;
  283. begin
  284.   GetProcedureAddress(_EnumPwrSchemes, powrprof_lib, 'EnumPwrSchemes');
  285.   asm
  286.     mov esp, ebp
  287.     pop ebp
  288.     jmp [_EnumPwrSchemes]
  289.   end;
  290. end;
  291. {$ELSE}
  292. function EnumPwrSchemes; external powrprof_lib name 'EnumPwrSchemes';
  293. {$ENDIF DYNAMIC_LINK}
  294. {$IFDEF DYNAMIC_LINK}
  295. var
  296.   _ReadGlobalPwrPolicy: Pointer;
  297. function ReadGlobalPwrPolicy;
  298. begin
  299.   GetProcedureAddress(_ReadGlobalPwrPolicy, powrprof_lib, 'ReadGlobalPwrPolicy');
  300.   asm
  301.     mov esp, ebp
  302.     pop ebp
  303.     jmp [_ReadGlobalPwrPolicy]
  304.   end;
  305. end;
  306. {$ELSE}
  307. function ReadGlobalPwrPolicy; external powrprof_lib name 'ReadGlobalPwrPolicy';
  308. {$ENDIF DYNAMIC_LINK}
  309. {$IFDEF DYNAMIC_LINK}
  310. var
  311.   _ReadPwrScheme: Pointer;
  312. function ReadPwrScheme;
  313. begin
  314.   GetProcedureAddress(_ReadPwrScheme, powrprof_lib, 'ReadPwrScheme');
  315.   asm
  316.     mov esp, ebp
  317.     pop ebp
  318.     jmp [_ReadPwrScheme]
  319.   end;
  320. end;
  321. {$ELSE}
  322. function ReadPwrScheme; external powrprof_lib name 'ReadPwrScheme';
  323. {$ENDIF DYNAMIC_LINK}
  324. {$IFDEF DYNAMIC_LINK}
  325. var
  326.   _WritePwrScheme: Pointer;
  327. function WritePwrScheme;
  328. begin
  329.   GetProcedureAddress(_WritePwrScheme, powrprof_lib, 'WritePwrScheme');
  330.   asm
  331.     mov esp, ebp
  332.     pop ebp
  333.     jmp [_WritePwrScheme]
  334.   end;
  335. end;
  336. {$ELSE}
  337. function WritePwrScheme; external powrprof_lib name 'WritePwrScheme';
  338. {$ENDIF DYNAMIC_LINK}
  339. {$IFDEF DYNAMIC_LINK}
  340. var
  341.   _WriteGlobalPwrPolicy: Pointer;
  342. function WriteGlobalPwrPolicy;
  343. begin
  344.   GetProcedureAddress(_WriteGlobalPwrPolicy, powrprof_lib, 'WriteGlobalPwrPolicy');
  345.   asm
  346.     mov esp, ebp
  347.     pop ebp
  348.     jmp [_WriteGlobalPwrPolicy]
  349.   end;
  350. end;
  351. {$ELSE}
  352. function WriteGlobalPwrPolicy; external powrprof_lib name 'WriteGlobalPwrPolicy';
  353. {$ENDIF DYNAMIC_LINK}
  354. {$IFDEF DYNAMIC_LINK}
  355. var
  356.   _DeletePwrScheme: Pointer;
  357. function DeletePwrScheme;
  358. begin
  359.   GetProcedureAddress(_DeletePwrScheme, powrprof_lib, 'DeletePwrScheme');
  360.   asm
  361.     mov esp, ebp
  362.     pop ebp
  363.     jmp [_DeletePwrScheme]
  364.   end;
  365. end;
  366. {$ELSE}
  367. function DeletePwrScheme; external powrprof_lib name 'DeletePwrScheme';
  368. {$ENDIF DYNAMIC_LINK}
  369. {$IFDEF DYNAMIC_LINK}
  370. var
  371.   _GetActivePwrScheme: Pointer;
  372. function GetActivePwrScheme;
  373. begin
  374.   GetProcedureAddress(_GetActivePwrScheme, powrprof_lib, 'GetActivePwrScheme');
  375.   asm
  376.     mov esp, ebp
  377.     pop ebp
  378.     jmp [_GetActivePwrScheme]
  379.   end;
  380. end;
  381. {$ELSE}
  382. function GetActivePwrScheme; external powrprof_lib name 'GetActivePwrScheme';
  383. {$ENDIF DYNAMIC_LINK}
  384. {$IFDEF DYNAMIC_LINK}
  385. var
  386.   _SetActivePwrScheme: Pointer;
  387. function SetActivePwrScheme;
  388. begin
  389.   GetProcedureAddress(_SetActivePwrScheme, powrprof_lib, 'SetActivePwrScheme');
  390.   asm
  391.     mov esp, ebp
  392.     pop ebp
  393.     jmp [_SetActivePwrScheme]
  394.   end;
  395. end;
  396. {$ELSE}
  397. function SetActivePwrScheme; external powrprof_lib name 'SetActivePwrScheme';
  398. {$ENDIF DYNAMIC_LINK}
  399. {$IFDEF DYNAMIC_LINK}
  400. var
  401.   _GetPwrCapabilities: Pointer;
  402. function GetPwrCapabilities;
  403. begin
  404.   GetProcedureAddress(_GetPwrCapabilities, powrprof_lib, 'GetPwrCapabilities');
  405.   asm
  406.     mov esp, ebp
  407.     pop ebp
  408.     jmp [_GetPwrCapabilities]
  409.   end;
  410. end;
  411. {$ELSE}
  412. function GetPwrCapabilities; external powrprof_lib name 'GetPwrCapabilities';
  413. {$ENDIF DYNAMIC_LINK}
  414. {$IFDEF DYNAMIC_LINK}
  415. var
  416.   _IsPwrSuspendAllowed: Pointer;
  417. function IsPwrSuspendAllowed;
  418. begin
  419.   GetProcedureAddress(_IsPwrSuspendAllowed, powrprof_lib, 'IsPwrSuspendAllowed');
  420.   asm
  421.     mov esp, ebp
  422.     pop ebp
  423.     jmp [_IsPwrSuspendAllowed]
  424.   end;
  425. end;
  426. {$ELSE}
  427. function IsPwrSuspendAllowed; external powrprof_lib name 'IsPwrSuspendAllowed';
  428. {$ENDIF DYNAMIC_LINK}
  429. {$IFDEF DYNAMIC_LINK}
  430. var
  431.   _IsPwrHibernateAllowed: Pointer;
  432. function IsPwrHibernateAllowed;
  433. begin
  434.   GetProcedureAddress(_IsPwrHibernateAllowed, powrprof_lib, 'IsPwrHibernateAllowed');
  435.   asm
  436.     mov esp, ebp
  437.     pop ebp
  438.     jmp [_IsPwrHibernateAllowed]
  439.   end;
  440. end;
  441. {$ELSE}
  442. function IsPwrHibernateAllowed; external powrprof_lib name 'IsPwrHibernateAllowed';
  443. {$ENDIF DYNAMIC_LINK}
  444. {$IFDEF DYNAMIC_LINK}
  445. var
  446.   _IsPwrShutdownAllowed: Pointer;
  447. function IsPwrShutdownAllowed;
  448. begin
  449.   GetProcedureAddress(_IsPwrShutdownAllowed, powrprof_lib, 'IsPwrShutdownAllowed');
  450.   asm
  451.     mov esp, ebp
  452.     pop ebp
  453.     jmp [_IsPwrShutdownAllowed]
  454.   end;
  455. end;
  456. {$ELSE}
  457. function IsPwrShutdownAllowed; external powrprof_lib name 'IsPwrShutdownAllowed';
  458. {$ENDIF DYNAMIC_LINK}
  459. {$IFDEF DYNAMIC_LINK}
  460. var
  461.   _IsAdminOverrideActive: Pointer;
  462. function IsAdminOverrideActive;
  463. begin
  464.   GetProcedureAddress(_IsAdminOverrideActive, powrprof_lib, 'IsAdminOverrideActive');
  465.   asm
  466.     mov esp, ebp
  467.     pop ebp
  468.     jmp [_IsAdminOverrideActive]
  469.   end;
  470. end;
  471. {$ELSE}
  472. function IsAdminOverrideActive; external powrprof_lib name 'IsAdminOverrideActive';
  473. {$ENDIF DYNAMIC_LINK}
  474. {$IFDEF DYNAMIC_LINK}
  475. var
  476.   _SetSuspendState: Pointer;
  477. function SetSuspendState;
  478. begin
  479.   GetProcedureAddress(_SetSuspendState, powrprof_lib, 'SetSuspendState');
  480.   asm
  481.     mov esp, ebp
  482.     pop ebp
  483.     jmp [_SetSuspendState]
  484.   end;
  485. end;
  486. {$ELSE}
  487. function SetSuspendState; external powrprof_lib name 'SetSuspendState';
  488. {$ENDIF DYNAMIC_LINK}
  489. {$IFDEF DYNAMIC_LINK}
  490. var
  491.   _GetCurrentPowerPolicies: Pointer;
  492. function GetCurrentPowerPolicies;
  493. begin
  494.   GetProcedureAddress(_GetCurrentPowerPolicies, powrprof_lib, 'GetCurrentPowerPolicies');
  495.   asm
  496.     mov esp, ebp
  497.     pop ebp
  498.     jmp [_GetCurrentPowerPolicies]
  499.   end;
  500. end;
  501. {$ELSE}
  502. function GetCurrentPowerPolicies; external powrprof_lib name 'GetCurrentPowerPolicies';
  503. {$ENDIF DYNAMIC_LINK}
  504. {$IFDEF DYNAMIC_LINK}
  505. var
  506.   _CanUserWritePwrScheme: Pointer;
  507. function CanUserWritePwrScheme;
  508. begin
  509.   GetProcedureAddress(_CanUserWritePwrScheme, powrprof_lib, 'CanUserWritePwrScheme');
  510.   asm
  511.     mov esp, ebp
  512.     pop ebp
  513.     jmp [_CanUserWritePwrScheme]
  514.   end;
  515. end;
  516. {$ELSE}
  517. function CanUserWritePwrScheme; external powrprof_lib name 'CanUserWritePwrScheme';
  518. {$ENDIF DYNAMIC_LINK}
  519. {$IFDEF DYNAMIC_LINK}
  520. var
  521.   _ReadProcessorPwrScheme: Pointer;
  522. function ReadProcessorPwrScheme;
  523. begin
  524.   GetProcedureAddress(_ReadProcessorPwrScheme, powrprof_lib, 'ReadProcessorPwrScheme');
  525.   asm
  526.     mov esp, ebp
  527.     pop ebp
  528.     jmp [_ReadProcessorPwrScheme]
  529.   end;
  530. end;
  531. {$ELSE}
  532. function ReadProcessorPwrScheme; external powrprof_lib name 'ReadProcessorPwrScheme';
  533. {$ENDIF DYNAMIC_LINK}
  534. {$IFDEF DYNAMIC_LINK}
  535. var
  536.   _WriteProcessorPwrScheme: Pointer;
  537. function WriteProcessorPwrScheme;
  538. begin
  539.   GetProcedureAddress(_WriteProcessorPwrScheme, powrprof_lib, 'WriteProcessorPwrScheme');
  540.   asm
  541.     mov esp, ebp
  542.     pop ebp
  543.     jmp [_WriteProcessorPwrScheme]
  544.   end;
  545. end;
  546. {$ELSE}
  547. function WriteProcessorPwrScheme; external powrprof_lib name 'WriteProcessorPwrScheme';
  548. {$ENDIF DYNAMIC_LINK}
  549. {$IFDEF DYNAMIC_LINK}
  550. var
  551.   _ValidatePowerPolicies: Pointer;
  552. function ValidatePowerPolicies;
  553. begin
  554.   GetProcedureAddress(_ValidatePowerPolicies, powrprof_lib, 'ValidatePowerPolicies');
  555.   asm
  556.     mov esp, ebp
  557.     pop ebp
  558.     jmp [_ValidatePowerPolicies]
  559.   end;
  560. end;
  561. {$ELSE}
  562. function ValidatePowerPolicies; external powrprof_lib name 'ValidatePowerPolicies';
  563. {$ENDIF DYNAMIC_LINK}
  564. {$IFDEF DYNAMIC_LINK}
  565. var
  566.   _CallNtPowerInformation: Pointer;
  567. function CallNtPowerInformation;
  568. begin
  569.   GetProcedureAddress(_CallNtPowerInformation, powrprof_lib, 'CallNtPowerInformation');
  570.   asm
  571.     mov esp, ebp
  572.     pop ebp
  573.     jmp [_CallNtPowerInformation]
  574.   end;
  575. end;
  576. {$ELSE}
  577. function CallNtPowerInformation; external powrprof_lib name 'CallNtPowerInformation';
  578. {$ENDIF DYNAMIC_LINK}
  579. end.