unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComObj,
ActiveX;
const PWR_PROF = '
PowrProf.dll';
{$EXTERNALSYM _POWER_DATA_ACCESSOR}
const NO_SUBGROUP_GUID: TGUID = '
{fea3413e-7e05-4911-9a71-700331f1c294}';
GUID_DISK_SUBGROUP: TGUID = '
{0012ee47-9041-4b5d-9b77-535fba8b1442}';
GUID_SYSTEM_BUTTON_SUBGROUP: TGUID = '
{4f971e89-eebd-4455-a8de-9e59040e7347}';
GUID_PROCESSOR_SETTINGS_SUBGROUP: TGUID = '
{54533251-82be-4824-96c1-47b60b740d00}';
GUID_VIDEO_SUBGROUP: TGUID = '
{7516b95f-f776-4464-8c53-06167f40cc99}';
GUID_BATTERY_SUBGROUP: TGUID = '
{e73a048d-bf27-4f12-9731-8b2076e8891f}';
GUID_SLEEP_SUBGROUP: TGUID = '
{238C9FA8-0AAD-41ED-83F4-97BE242C8F20}';
GUID_PCIEXPRESS_SETTINGS_SUBGROUP: TGUID = '
{501a4d13-42af-4429-9fd1-a8218c268e20}';
type
_POWER_DATA_ACCESSOR = (
ACCESS_AC_POWER_SETTING_INDEX,
ACCESS_DC_POWER_SETTING_INDEX,
ACCESS_SCHEME,
ACCESS_SUBGROUP,
ACCESS_INDIVIDUAL_SETTING,
ACCESS_ACTIVE_SCHEME,
ACCESS_CREATE_SCHEME
);
{$EXTERNALSYM POWER_DATA_ACCESSOR}
POWER_DATA_ACCESSOR = _POWER_DATA_ACCESSOR;
{$EXTERNALSYM PPOWER_DATA_ACCESSOR}
PPOWER_DATA_ACCESSOR = ^_POWER_DATA_ACCESSOR;
TForm1 =
class(TForm)
Button1: TButton;
Memo: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
{$EXTERNALSYM PowerSetActiveScheme}
function PowerSetActiveScheme(UserRootPowerKey: HKEY;
const SchemeGUID: PGUID):
DWORD;
stdcall;
external PWR_PROF;
{$EXTERNALSYM PowerEnumerate}
function PowerEnumerate(UserRootPowerKey: HKEY;
const SchemeGuid: PGUID;
const SubGroupOfPowerSettingGuid: PGUID; AccessFlag: POWER_DATA_ACCESSOR;
Index: ULONG; Buffer: PUCHAR; BufferSize: PDWORD):
DWORD;
stdcall;
external PWR_PROF;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var res, size: DWORD;
i: ULONG;
tmp: TGUID;
begin
i := 0;
size := SizeOf(TGUID);
repeat
res := PowerEnumerate(0,
nil,
nil, ACCESS_SCHEME, i, @tmp, @size);
if res = ERROR_SUCCESS
then
Memo.Lines.Add(GUIDToString(tmp));
Inc(i);
until res <> ERROR_SUCCESS;
end;
end.