@bun-win32/powrprof 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI.md +73 -0
- package/README.md +67 -0
- package/index.ts +4 -0
- package/package.json +56 -0
- package/structs/PowrProf.ts +616 -0
- package/types/PowrProf.ts +112 -0
package/AI.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# AI Guide for @bun-win32/powrprof
|
|
2
|
+
|
|
3
|
+
How to use this package, not what the Win32 API does.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import PowrProf, { POWER_INFORMATION_LEVEL } from '@bun-win32/powrprof';
|
|
9
|
+
|
|
10
|
+
// Methods bind lazily on first call
|
|
11
|
+
const result = PowrProf.CallNtPowerInformation(level, null, 0, buf.ptr, buf.byteLength);
|
|
12
|
+
|
|
13
|
+
// Preload: array, single string, or no args (all symbols)
|
|
14
|
+
PowrProf.Preload(['CallNtPowerInformation', 'PowerGetActiveScheme']);
|
|
15
|
+
PowrProf.Preload('SetSuspendState');
|
|
16
|
+
PowrProf.Preload();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Where To Look
|
|
20
|
+
|
|
21
|
+
| Need | Read |
|
|
22
|
+
| --------------------------------- | --------------------- |
|
|
23
|
+
| Find a method or its MS Docs link | `structs/PowrProf.ts` |
|
|
24
|
+
| Find types, enums, constants | `types/PowrProf.ts` |
|
|
25
|
+
| Quick examples | `README.md` |
|
|
26
|
+
|
|
27
|
+
`index.ts` re-exports the class and all types — import from `@bun-win32/powrprof` directly.
|
|
28
|
+
|
|
29
|
+
## Calling Convention
|
|
30
|
+
|
|
31
|
+
All documented `powrprof.dll` exports are bound. Each method maps 1:1 to its DLL export. Names, parameter names, and order match Microsoft Docs.
|
|
32
|
+
|
|
33
|
+
### Strings
|
|
34
|
+
|
|
35
|
+
Most powrprof functions work with GUIDs and binary data rather than strings. Where strings are used (e.g. `WritePwrScheme`), they take UTF-16LE NUL-terminated buffers.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const wide = Buffer.from('My Scheme\0', 'utf16le'); // LPCWSTR
|
|
39
|
+
PowrProf.WritePwrScheme(idBuf.ptr, wide.ptr, null, policyBuf.ptr);
|
|
40
|
+
|
|
41
|
+
// Reading a wide string back from a buffer:
|
|
42
|
+
const text = new TextDecoder('utf-16').decode(buf).replace(/\0.*$/, '');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Return types
|
|
46
|
+
|
|
47
|
+
- `HANDLE`, `HKEY`, `HPOWERNOTIFY` → `bigint`
|
|
48
|
+
- `DWORD`, `UINT`, `BOOL`, `ULONG`, `REGSAM`, `NTSTATUS` → `number`
|
|
49
|
+
- `BOOLEAN` → `number` (0 or 1, unsigned byte)
|
|
50
|
+
- `HRESULT` → `number` (signed 32-bit)
|
|
51
|
+
- `LPVOID`, `LPWSTR`, `LPCGUID`, `PUCHAR`, etc. → `Pointer`
|
|
52
|
+
- Win32 `BOOL` is `number` (0 or non-zero), **not** JS `boolean`. Do not compare with `=== true`.
|
|
53
|
+
|
|
54
|
+
### Pointers, handles, out-parameters
|
|
55
|
+
|
|
56
|
+
- **Pointer** params (`LPCGUID`, `PUCHAR`, `Pointer`): pass `buffer.ptr` from a caller-allocated `Buffer`.
|
|
57
|
+
- **Handle** params (`HKEY`, `HANDLE`, `HPOWERNOTIFY`): pass a `bigint` value.
|
|
58
|
+
- **Out-parameters**: allocate a `Buffer`, pass `.ptr`, read the result after the call.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const out = Buffer.alloc(4);
|
|
62
|
+
PowrProf.PowerReadACValueIndex(0n, schemeGuid.ptr, null, settingGuid.ptr, out.ptr);
|
|
63
|
+
const value = new DataView(out.buffer).getUint32(0, true);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Nullability
|
|
67
|
+
|
|
68
|
+
- `| NULL` in a signature → pass `null` (optional pointer).
|
|
69
|
+
- `| 0n` in a signature → pass `0n` (optional handle).
|
|
70
|
+
|
|
71
|
+
## Errors and Cleanup
|
|
72
|
+
|
|
73
|
+
Return values are raw. Most modern Power* functions return `DWORD` error codes (`0` = `ERROR_SUCCESS`). Legacy functions return `BOOLEAN` (`1` = success, `0` = failure). `CallNtPowerInformation` returns `NTSTATUS` (`0` = `STATUS_SUCCESS`). Resource cleanup is your responsibility — same as raw Win32.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @bun-win32/powrprof
|
|
2
|
+
|
|
3
|
+
Zero-dependency, zero-overhead Win32 PowrProf bindings for [Bun](https://bun.sh) on Windows.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@bun-win32/powrprof` exposes the `powrprof.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `PowrProf`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.
|
|
8
|
+
|
|
9
|
+
The bindings are strongly typed for a smooth DX in TypeScript.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.
|
|
14
|
+
- Direct FFI to `powrprof.dll` (power schemes, policies, sleep states, and battery management).
|
|
15
|
+
- In-source docs in `structs/PowrProf.ts` with links to Microsoft Docs.
|
|
16
|
+
- Lazy binding on first call; optional eager preload (`PowrProf.Preload()`).
|
|
17
|
+
- No wrapper overhead; calls map 1:1 to native APIs.
|
|
18
|
+
- Strongly-typed Win32 aliases (see `types/PowrProf.ts`).
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- [Bun](https://bun.sh) runtime
|
|
23
|
+
- Windows 10 or later
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
bun add @bun-win32/powrprof
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import PowrProf, { POWER_INFORMATION_LEVEL } from '@bun-win32/powrprof';
|
|
35
|
+
|
|
36
|
+
// Get system battery state
|
|
37
|
+
const batteryState = Buffer.alloc(64);
|
|
38
|
+
const status = PowrProf.CallNtPowerInformation(
|
|
39
|
+
POWER_INFORMATION_LEVEL.SystemBatteryState,
|
|
40
|
+
null, 0,
|
|
41
|
+
batteryState.ptr, batteryState.byteLength,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (status === 0) {
|
|
45
|
+
const view = new DataView(batteryState.buffer);
|
|
46
|
+
const acOnLine = view.getUint8(0);
|
|
47
|
+
const batteryPresent = view.getUint8(1);
|
|
48
|
+
console.log(`AC: ${acOnLine ? 'plugged in' : 'battery'}`);
|
|
49
|
+
console.log(`Battery present: ${batteryPresent ? 'yes' : 'no'}`);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> [!NOTE]
|
|
54
|
+
> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
Run the included examples:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
bun run example/powrprof.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
65
|
+
|
|
66
|
+
- Either rely on lazy binding or call `PowrProf.Preload()`.
|
|
67
|
+
- Windows only. Bun runtime required.
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Stev Peifer <stev@bell.net>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/ObscuritySRL/bun-win32/issues"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@bun-win32/core": "1.1.1"
|
|
8
|
+
},
|
|
9
|
+
"description": "Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/bun": "latest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./index.ts"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"module": "index.ts",
|
|
18
|
+
"name": "@bun-win32/powrprof",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"typescript": "^5"
|
|
21
|
+
},
|
|
22
|
+
"private": false,
|
|
23
|
+
"homepage": "https://github.com/ObscuritySRL/bun-win32#readme",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git://github.com/ObscuritySRL/bun-win32.git",
|
|
27
|
+
"directory": "packages/powrprof"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"main": "./index.ts",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"bun",
|
|
34
|
+
"ffi",
|
|
35
|
+
"win32",
|
|
36
|
+
"windows",
|
|
37
|
+
"powrprof",
|
|
38
|
+
"bindings",
|
|
39
|
+
"typescript",
|
|
40
|
+
"dll"
|
|
41
|
+
],
|
|
42
|
+
"files": [
|
|
43
|
+
"AI.md",
|
|
44
|
+
"README.md",
|
|
45
|
+
"index.ts",
|
|
46
|
+
"structs/*.ts",
|
|
47
|
+
"types/*.ts"
|
|
48
|
+
],
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"engines": {
|
|
51
|
+
"bun": ">=1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"example": "bun ./example/powrprof.ts"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import { type FFIFunction, FFIType } from 'bun:ffi';
|
|
2
|
+
import { Win32 } from '@bun-win32/core';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
BOOL,
|
|
6
|
+
BOOLEAN,
|
|
7
|
+
DWORD,
|
|
8
|
+
EFFECTIVE_POWER_MODE_CALLBACK,
|
|
9
|
+
HANDLE,
|
|
10
|
+
HKEY,
|
|
11
|
+
HPOWERNOTIFY,
|
|
12
|
+
HRESULT,
|
|
13
|
+
LPCGUID,
|
|
14
|
+
LPCWSTR,
|
|
15
|
+
LPDWORD,
|
|
16
|
+
LPGUID,
|
|
17
|
+
LPARAM,
|
|
18
|
+
LPBYTE,
|
|
19
|
+
NULL,
|
|
20
|
+
NTSTATUS,
|
|
21
|
+
PADMINISTRATOR_POWER_POLICY,
|
|
22
|
+
PBYTE,
|
|
23
|
+
PGLOBAL_POWER_POLICY,
|
|
24
|
+
PHPOWERNOTIFY,
|
|
25
|
+
PMACHINE_PROCESSOR_POWER_POLICY,
|
|
26
|
+
POWER_DATA_ACCESSOR,
|
|
27
|
+
POWER_INFORMATION_LEVEL,
|
|
28
|
+
POWER_PLATFORM_ROLE,
|
|
29
|
+
PPOWER_POLICY,
|
|
30
|
+
PSYSTEM_POWER_CAPABILITIES,
|
|
31
|
+
PTHERMAL_EVENT,
|
|
32
|
+
PUCHAR,
|
|
33
|
+
PUINT,
|
|
34
|
+
PULONG,
|
|
35
|
+
PVOID,
|
|
36
|
+
PWRSCHEMESENUMPROC,
|
|
37
|
+
REGSAM,
|
|
38
|
+
UINT,
|
|
39
|
+
ULONG,
|
|
40
|
+
} from '../types/PowrProf';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Thin, lazy-loaded FFI bindings for `powrprof.dll`.
|
|
44
|
+
*
|
|
45
|
+
* Each static method corresponds one-to-one with a Win32 export declared in `Symbols`.
|
|
46
|
+
* The first call to a method binds the underlying native symbol via `bun:ffi` and
|
|
47
|
+
* memoizes it on the class for subsequent calls. For bulk, up-front binding, use `Preload`.
|
|
48
|
+
*
|
|
49
|
+
* Symbols are defined with explicit `FFIType` signatures and kept alphabetized.
|
|
50
|
+
* You normally do not access `Symbols` directly; call the static methods or preload
|
|
51
|
+
* a subset for hot paths.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import PowrProf from './structs/PowrProf';
|
|
56
|
+
*
|
|
57
|
+
* // Lazy: bind on first call
|
|
58
|
+
* const result = PowrProf.GetPwrCapabilities(buffer.ptr);
|
|
59
|
+
*
|
|
60
|
+
* // Or preload a subset to avoid per-symbol lazy binding cost
|
|
61
|
+
* PowrProf.Preload(['GetPwrCapabilities', 'PowerGetActiveScheme']);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
class PowrProf extends Win32 {
|
|
65
|
+
protected static override name = 'powrprof.dll';
|
|
66
|
+
|
|
67
|
+
/** @inheritdoc */
|
|
68
|
+
protected static override readonly Symbols = {
|
|
69
|
+
CallNtPowerInformation: { args: [FFIType.i32, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
70
|
+
CanUserWritePwrScheme: { args: [], returns: FFIType.u8 },
|
|
71
|
+
DeletePwrScheme: { args: [FFIType.u32], returns: FFIType.u8 },
|
|
72
|
+
DevicePowerClose: { args: [], returns: FFIType.u8 },
|
|
73
|
+
DevicePowerEnumDevices: { args: [FFIType.u32, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
74
|
+
DevicePowerOpen: { args: [FFIType.u32], returns: FFIType.u8 },
|
|
75
|
+
DevicePowerSetDeviceState: { args: [FFIType.ptr, FFIType.u32, FFIType.ptr], returns: FFIType.u32 },
|
|
76
|
+
EnumPwrSchemes: { args: [FFIType.ptr, FFIType.i64], returns: FFIType.u8 },
|
|
77
|
+
GetActivePwrScheme: { args: [FFIType.ptr], returns: FFIType.u8 },
|
|
78
|
+
GetCurrentPowerPolicies: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
79
|
+
GetPwrCapabilities: { args: [FFIType.ptr], returns: FFIType.u8 },
|
|
80
|
+
GetPwrDiskSpindownRange: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
81
|
+
IsAdminOverrideActive: { args: [FFIType.ptr], returns: FFIType.u8 },
|
|
82
|
+
IsPwrHibernateAllowed: { args: [], returns: FFIType.u8 },
|
|
83
|
+
IsPwrShutdownAllowed: { args: [], returns: FFIType.u8 },
|
|
84
|
+
IsPwrSuspendAllowed: { args: [], returns: FFIType.u8 },
|
|
85
|
+
PowerCanRestoreIndividualDefaultPowerScheme: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
86
|
+
PowerCreatePossibleSetting: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
87
|
+
PowerCreateSetting: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
88
|
+
PowerDeleteScheme: { args: [FFIType.u64, FFIType.ptr], returns: FFIType.u32 },
|
|
89
|
+
PowerDeterminePlatformRole: { args: [], returns: FFIType.i32 },
|
|
90
|
+
PowerDeterminePlatformRoleEx: { args: [FFIType.u32], returns: FFIType.i32 },
|
|
91
|
+
PowerDuplicateScheme: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
92
|
+
PowerEnumerate: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.i32, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
93
|
+
PowerGetActiveScheme: { args: [FFIType.u64, FFIType.ptr], returns: FFIType.u32 },
|
|
94
|
+
PowerGetUserConfiguredACPowerMode: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
95
|
+
PowerGetUserConfiguredDCPowerMode: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
96
|
+
PowerImportPowerScheme: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
97
|
+
PowerIsSettingRangeDefined: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
98
|
+
PowerOpenSystemPowerKey: { args: [FFIType.ptr, FFIType.u32, FFIType.i32], returns: FFIType.u32 },
|
|
99
|
+
PowerOpenUserPowerKey: { args: [FFIType.ptr, FFIType.u32, FFIType.i32], returns: FFIType.u32 },
|
|
100
|
+
PowerReadACDefaultIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
101
|
+
PowerReadACValue: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
102
|
+
PowerReadACValueIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
103
|
+
PowerReadDCDefaultIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
104
|
+
PowerReadDCValue: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
105
|
+
PowerReadDCValueIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
106
|
+
PowerReadDescription: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
107
|
+
PowerReadFriendlyName: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
108
|
+
PowerReadIconResourceSpecifier: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
109
|
+
PowerReadPossibleDescription: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
110
|
+
PowerReadPossibleFriendlyName: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
111
|
+
PowerReadPossibleValue: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
112
|
+
PowerReadSettingAttributes: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
113
|
+
PowerReadValueIncrement: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
114
|
+
PowerReadValueMax: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
115
|
+
PowerReadValueMin: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
116
|
+
PowerReadValueUnitsSpecifier: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
117
|
+
PowerRegisterForEffectivePowerModeNotifications: { args: [FFIType.u32, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
118
|
+
PowerRegisterSuspendResumeNotification: { args: [FFIType.u32, FFIType.u64, FFIType.ptr], returns: FFIType.u32 },
|
|
119
|
+
PowerRemovePowerSetting: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u32 },
|
|
120
|
+
PowerReplaceDefaultPowerSchemes: { args: [], returns: FFIType.u32 },
|
|
121
|
+
PowerReportThermalEvent: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
122
|
+
PowerRestoreDefaultPowerSchemes: { args: [], returns: FFIType.u32 },
|
|
123
|
+
PowerRestoreIndividualDefaultPowerScheme: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
124
|
+
PowerSetActiveScheme: { args: [FFIType.u64, FFIType.ptr], returns: FFIType.u32 },
|
|
125
|
+
PowerSetUserConfiguredACPowerMode: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
126
|
+
PowerSetUserConfiguredDCPowerMode: { args: [FFIType.ptr], returns: FFIType.u32 },
|
|
127
|
+
PowerSettingAccessCheck: { args: [FFIType.i32, FFIType.ptr], returns: FFIType.u32 },
|
|
128
|
+
PowerSettingAccessCheckEx: { args: [FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
129
|
+
PowerSettingRegisterNotification: { args: [FFIType.ptr, FFIType.u32, FFIType.u64, FFIType.ptr], returns: FFIType.u32 },
|
|
130
|
+
PowerSettingUnregisterNotification: { args: [FFIType.u64], returns: FFIType.u32 },
|
|
131
|
+
PowerUnregisterFromEffectivePowerModeNotifications: { args: [FFIType.u64], returns: FFIType.i32 },
|
|
132
|
+
PowerUnregisterSuspendResumeNotification: { args: [FFIType.u64], returns: FFIType.u32 },
|
|
133
|
+
PowerWriteACDefaultIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
134
|
+
PowerWriteACValueIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
135
|
+
PowerWriteDCDefaultIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
136
|
+
PowerWriteDCValueIndex: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
137
|
+
PowerWriteDescription: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
138
|
+
PowerWriteFriendlyName: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
139
|
+
PowerWriteIconResourceSpecifier: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
140
|
+
PowerWritePossibleDescription: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
141
|
+
PowerWritePossibleFriendlyName: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
142
|
+
PowerWritePossibleValue: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
143
|
+
PowerWriteSettingAttributes: { args: [FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
144
|
+
PowerWriteValueIncrement: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
145
|
+
PowerWriteValueMax: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
146
|
+
PowerWriteValueMin: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
147
|
+
PowerWriteValueUnitsSpecifier: { args: [FFIType.u64, FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.u32 },
|
|
148
|
+
ReadGlobalPwrPolicy: { args: [FFIType.ptr], returns: FFIType.u8 },
|
|
149
|
+
ReadProcessorPwrScheme: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.u8 },
|
|
150
|
+
ReadPwrScheme: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.u8 },
|
|
151
|
+
SetActivePwrScheme: { args: [FFIType.u32, FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
152
|
+
SetSuspendState: { args: [FFIType.u8, FFIType.u8, FFIType.u8], returns: FFIType.u8 },
|
|
153
|
+
ValidatePowerPolicies: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
154
|
+
WriteGlobalPwrPolicy: { args: [FFIType.ptr], returns: FFIType.u8 },
|
|
155
|
+
WriteProcessorPwrScheme: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.u8 },
|
|
156
|
+
WritePwrScheme: { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.u8 },
|
|
157
|
+
} as const satisfies Record<string, FFIFunction>;
|
|
158
|
+
|
|
159
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-callntpowerinformation
|
|
160
|
+
public static CallNtPowerInformation(InformationLevel: POWER_INFORMATION_LEVEL, InputBuffer: PVOID | NULL, InputBufferLength: ULONG, OutputBuffer: PVOID | NULL, OutputBufferLength: ULONG): NTSTATUS {
|
|
161
|
+
return PowrProf.Load('CallNtPowerInformation')(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-canuserwritepwrscheme
|
|
165
|
+
public static CanUserWritePwrScheme(): BOOLEAN {
|
|
166
|
+
return PowrProf.Load('CanUserWritePwrScheme')();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-deletepwrscheme
|
|
170
|
+
public static DeletePwrScheme(uiID: UINT): BOOLEAN {
|
|
171
|
+
return PowrProf.Load('DeletePwrScheme')(uiID);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-devicepowerclose
|
|
175
|
+
public static DevicePowerClose(): BOOLEAN {
|
|
176
|
+
return PowrProf.Load('DevicePowerClose')();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-devicepowerenumdevices
|
|
180
|
+
public static DevicePowerEnumDevices(QueryIndex: ULONG, QueryInterpretationFlags: ULONG, QueryFlags: ULONG, pReturnBuffer: PBYTE | NULL, pBufferSize: PULONG): BOOLEAN {
|
|
181
|
+
return PowrProf.Load('DevicePowerEnumDevices')(QueryIndex, QueryInterpretationFlags, QueryFlags, pReturnBuffer, pBufferSize);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-devicepoweropen
|
|
185
|
+
public static DevicePowerOpen(DebugMask: ULONG): BOOLEAN {
|
|
186
|
+
return PowrProf.Load('DevicePowerOpen')(DebugMask);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-devicepowersetdevicestate
|
|
190
|
+
public static DevicePowerSetDeviceState(DeviceDescription: LPCWSTR, SetFlags: ULONG, SetData: PVOID | NULL): DWORD {
|
|
191
|
+
return PowrProf.Load('DevicePowerSetDeviceState')(DeviceDescription, SetFlags, SetData);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-enumpwrschemes
|
|
195
|
+
public static EnumPwrSchemes(lpfn: PWRSCHEMESENUMPROC, lParam: LPARAM): BOOLEAN {
|
|
196
|
+
return PowrProf.Load('EnumPwrSchemes')(lpfn, lParam);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-getactivepwrscheme
|
|
200
|
+
public static GetActivePwrScheme(puiID: PUINT): BOOLEAN {
|
|
201
|
+
return PowrProf.Load('GetActivePwrScheme')(puiID);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-getcurrentpowerpolicies
|
|
205
|
+
public static GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, pPowerPolicy: PPOWER_POLICY): BOOLEAN {
|
|
206
|
+
return PowrProf.Load('GetCurrentPowerPolicies')(pGlobalPowerPolicy, pPowerPolicy);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-getpwrcapabilities
|
|
210
|
+
public static GetPwrCapabilities(lpspc: PSYSTEM_POWER_CAPABILITIES): BOOLEAN {
|
|
211
|
+
return PowrProf.Load('GetPwrCapabilities')(lpspc);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-getpwrdiskspindownrange
|
|
215
|
+
public static GetPwrDiskSpindownRange(puiMax: PUINT, puiMin: PUINT): BOOLEAN {
|
|
216
|
+
return PowrProf.Load('GetPwrDiskSpindownRange')(puiMax, puiMin);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-isadminoverrideactive
|
|
220
|
+
public static IsAdminOverrideActive(papp: PADMINISTRATOR_POWER_POLICY): BOOLEAN {
|
|
221
|
+
return PowrProf.Load('IsAdminOverrideActive')(papp);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-ispwrhibernateallowed
|
|
225
|
+
public static IsPwrHibernateAllowed(): BOOLEAN {
|
|
226
|
+
return PowrProf.Load('IsPwrHibernateAllowed')();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-ispwrshutdownallowed
|
|
230
|
+
public static IsPwrShutdownAllowed(): BOOLEAN {
|
|
231
|
+
return PowrProf.Load('IsPwrShutdownAllowed')();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-ispwrsuspendallowed
|
|
235
|
+
public static IsPwrSuspendAllowed(): BOOLEAN {
|
|
236
|
+
return PowrProf.Load('IsPwrSuspendAllowed')();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powercanrestoreindividualdefaultpowerscheme
|
|
240
|
+
public static PowerCanRestoreIndividualDefaultPowerScheme(SchemeGuid: LPCGUID): DWORD {
|
|
241
|
+
return PowrProf.Load('PowerCanRestoreIndividualDefaultPowerScheme')(SchemeGuid);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powercreatepossiblesetting
|
|
245
|
+
public static PowerCreatePossibleSetting(RootSystemPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID, PowerSettingGuid: LPCGUID, PossibleSettingIndex: ULONG): DWORD {
|
|
246
|
+
return PowrProf.Load('PowerCreatePossibleSetting')(RootSystemPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, PossibleSettingIndex);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powercreatesetting
|
|
250
|
+
public static PowerCreateSetting(RootSystemPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID, PowerSettingGuid: LPCGUID): DWORD {
|
|
251
|
+
return PowrProf.Load('PowerCreateSetting')(RootSystemPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerdeletescheme
|
|
255
|
+
public static PowerDeleteScheme(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID): DWORD {
|
|
256
|
+
return PowrProf.Load('PowerDeleteScheme')(RootPowerKey, SchemeGuid);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerdetermineplatformrole
|
|
260
|
+
public static PowerDeterminePlatformRole(): POWER_PLATFORM_ROLE {
|
|
261
|
+
return PowrProf.Load('PowerDeterminePlatformRole')();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-powerdetermineplatformroleex
|
|
265
|
+
public static PowerDeterminePlatformRoleEx(Version: ULONG): POWER_PLATFORM_ROLE {
|
|
266
|
+
return PowrProf.Load('PowerDeterminePlatformRoleEx')(Version);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerduplicatescheme
|
|
270
|
+
public static PowerDuplicateScheme(RootPowerKey: HKEY | 0n, SourceSchemeGuid: LPCGUID, DestinationSchemeGuid: PVOID): DWORD {
|
|
271
|
+
return PowrProf.Load('PowerDuplicateScheme')(RootPowerKey, SourceSchemeGuid, DestinationSchemeGuid);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerenumerate
|
|
275
|
+
public static PowerEnumerate(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, AccessFlags: POWER_DATA_ACCESSOR, Index: ULONG, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
276
|
+
return PowrProf.Load('PowerEnumerate')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, AccessFlags, Index, Buffer, BufferSize);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powergetactivescheme
|
|
280
|
+
public static PowerGetActiveScheme(UserRootPowerKey: HKEY | 0n, ActivePolicyGuid: PVOID): DWORD {
|
|
281
|
+
return PowrProf.Load('PowerGetActiveScheme')(UserRootPowerKey, ActivePolicyGuid);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powergetuserconfiguredacpowermode
|
|
285
|
+
public static PowerGetUserConfiguredACPowerMode(PowerModeGuid: LPGUID): DWORD {
|
|
286
|
+
return PowrProf.Load('PowerGetUserConfiguredACPowerMode')(PowerModeGuid);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powergetuserconfigureddcpowermode
|
|
290
|
+
public static PowerGetUserConfiguredDCPowerMode(PowerModeGuid: LPGUID): DWORD {
|
|
291
|
+
return PowrProf.Load('PowerGetUserConfiguredDCPowerMode')(PowerModeGuid);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerimportpowerscheme
|
|
295
|
+
public static PowerImportPowerScheme(RootPowerKey: HKEY | 0n, ImportFileNamePath: LPCWSTR, DestinationSchemeGuid: PVOID): DWORD {
|
|
296
|
+
return PowrProf.Load('PowerImportPowerScheme')(RootPowerKey, ImportFileNamePath, DestinationSchemeGuid);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerissettingrangedefined
|
|
300
|
+
public static PowerIsSettingRangeDefined(SubKeyGuid: LPCGUID | NULL, SettingGuid: LPCGUID | NULL): BOOLEAN {
|
|
301
|
+
return PowrProf.Load('PowerIsSettingRangeDefined')(SubKeyGuid, SettingGuid);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-poweropensystempowerkey
|
|
305
|
+
public static PowerOpenSystemPowerKey(phSystemPowerKey: PVOID, Access: REGSAM, OpenExisting: BOOL): DWORD {
|
|
306
|
+
return PowrProf.Load('PowerOpenSystemPowerKey')(phSystemPowerKey, Access, OpenExisting);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-poweropenuserpowerkey
|
|
310
|
+
public static PowerOpenUserPowerKey(phUserPowerKey: PVOID, Access: REGSAM, OpenExisting: BOOL): DWORD {
|
|
311
|
+
return PowrProf.Load('PowerOpenUserPowerKey')(phUserPowerKey, Access, OpenExisting);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadacdefaultindex
|
|
315
|
+
public static PowerReadACDefaultIndex(RootPowerKey: HKEY | 0n, SchemePersonalityGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID, AcDefaultIndex: LPDWORD): DWORD {
|
|
316
|
+
return PowrProf.Load('PowerReadACDefaultIndex')(RootPowerKey, SchemePersonalityGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, AcDefaultIndex);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerreadacvalue
|
|
320
|
+
public static PowerReadACValue(
|
|
321
|
+
RootPowerKey: HKEY | 0n,
|
|
322
|
+
SchemeGuid: LPCGUID | NULL,
|
|
323
|
+
SubGroupOfPowerSettingsGuid: LPCGUID | NULL,
|
|
324
|
+
PowerSettingGuid: LPCGUID | NULL,
|
|
325
|
+
Type: PULONG | NULL,
|
|
326
|
+
Buffer: LPBYTE | NULL,
|
|
327
|
+
BufferSize: LPDWORD | NULL,
|
|
328
|
+
): DWORD {
|
|
329
|
+
return PowrProf.Load('PowerReadACValue')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Type, Buffer, BufferSize);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadacvalueindex
|
|
333
|
+
public static PowerReadACValueIndex(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, AcValueIndex: LPDWORD): DWORD {
|
|
334
|
+
return PowrProf.Load('PowerReadACValueIndex')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, AcValueIndex);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreaddcdefaultindex
|
|
338
|
+
public static PowerReadDCDefaultIndex(RootPowerKey: HKEY | 0n, SchemePersonalityGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID, DcDefaultIndex: LPDWORD): DWORD {
|
|
339
|
+
return PowrProf.Load('PowerReadDCDefaultIndex')(RootPowerKey, SchemePersonalityGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcDefaultIndex);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerreaddcvalue
|
|
343
|
+
public static PowerReadDCValue(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Type: PULONG | NULL, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
344
|
+
return PowrProf.Load('PowerReadDCValue')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Type, Buffer, BufferSize);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreaddcvalueindex
|
|
348
|
+
public static PowerReadDCValueIndex(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, DcValueIndex: LPDWORD): DWORD {
|
|
349
|
+
return PowrProf.Load('PowerReadDCValueIndex')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreaddescription
|
|
353
|
+
public static PowerReadDescription(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
354
|
+
return PowrProf.Load('PowerReadDescription')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadfriendlyname
|
|
358
|
+
public static PowerReadFriendlyName(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
359
|
+
return PowrProf.Load('PowerReadFriendlyName')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadiconresourcespecifier
|
|
363
|
+
public static PowerReadIconResourceSpecifier(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID | NULL, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
364
|
+
return PowrProf.Load('PowerReadIconResourceSpecifier')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadpossibledescription
|
|
368
|
+
public static PowerReadPossibleDescription(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, PossibleSettingIndex: ULONG, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
369
|
+
return PowrProf.Load('PowerReadPossibleDescription')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, PossibleSettingIndex, Buffer, BufferSize);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadpossiblefriendlyname
|
|
373
|
+
public static PowerReadPossibleFriendlyName(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, PossibleSettingIndex: ULONG, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
374
|
+
return PowrProf.Load('PowerReadPossibleFriendlyName')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, PossibleSettingIndex, Buffer, BufferSize);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadpossiblevalue
|
|
378
|
+
public static PowerReadPossibleValue(
|
|
379
|
+
RootPowerKey: HKEY | 0n,
|
|
380
|
+
SubGroupOfPowerSettingsGuid: LPCGUID | NULL,
|
|
381
|
+
PowerSettingGuid: LPCGUID | NULL,
|
|
382
|
+
Type: PULONG | NULL,
|
|
383
|
+
PossibleSettingIndex: ULONG,
|
|
384
|
+
Buffer: PUCHAR | NULL,
|
|
385
|
+
BufferSize: LPDWORD,
|
|
386
|
+
): DWORD {
|
|
387
|
+
return PowrProf.Load('PowerReadPossibleValue')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Type, PossibleSettingIndex, Buffer, BufferSize);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadsettingattributes
|
|
391
|
+
public static PowerReadSettingAttributes(SubGroupGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL): DWORD {
|
|
392
|
+
return PowrProf.Load('PowerReadSettingAttributes')(SubGroupGuid, PowerSettingGuid);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadvalueincrement
|
|
396
|
+
public static PowerReadValueIncrement(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueIncrement: LPDWORD): DWORD {
|
|
397
|
+
return PowrProf.Load('PowerReadValueIncrement')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueIncrement);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadvaluemax
|
|
401
|
+
public static PowerReadValueMax(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueMaximum: LPDWORD): DWORD {
|
|
402
|
+
return PowrProf.Load('PowerReadValueMax')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueMaximum);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadvaluemin
|
|
406
|
+
public static PowerReadValueMin(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueMinimum: LPDWORD): DWORD {
|
|
407
|
+
return PowrProf.Load('PowerReadValueMin')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueMinimum);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreadvalueunitsspecifier
|
|
411
|
+
public static PowerReadValueUnitsSpecifier(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR | NULL, BufferSize: LPDWORD): DWORD {
|
|
412
|
+
return PowrProf.Load('PowerReadValueUnitsSpecifier')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerregisterforeffectivepowermodenotifications
|
|
416
|
+
public static PowerRegisterForEffectivePowerModeNotifications(Version: ULONG, Callback: EFFECTIVE_POWER_MODE_CALLBACK, Context: PVOID | NULL, RegistrationHandle: PVOID): HRESULT {
|
|
417
|
+
return PowrProf.Load('PowerRegisterForEffectivePowerModeNotifications')(Version, Callback, Context, RegistrationHandle);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-powerregistersuspendresumenotification
|
|
421
|
+
public static PowerRegisterSuspendResumeNotification(Flags: DWORD, Recipient: HANDLE, RegistrationHandle: PHPOWERNOTIFY): DWORD {
|
|
422
|
+
return PowrProf.Load('PowerRegisterSuspendResumeNotification')(Flags, Recipient, RegistrationHandle);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerremovepowersetting
|
|
426
|
+
public static PowerRemovePowerSetting(PowerSettingSubKeyGuid: LPCGUID, PowerSettingGuid: LPCGUID): DWORD {
|
|
427
|
+
return PowrProf.Load('PowerRemovePowerSetting')(PowerSettingSubKeyGuid, PowerSettingGuid);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreplacedefaultpowerschemes
|
|
431
|
+
public static PowerReplaceDefaultPowerSchemes(): DWORD {
|
|
432
|
+
return PowrProf.Load('PowerReplaceDefaultPowerSchemes')();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerreportthermalevent
|
|
436
|
+
public static PowerReportThermalEvent(Event: PTHERMAL_EVENT): DWORD {
|
|
437
|
+
return PowrProf.Load('PowerReportThermalEvent')(Event);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerrestoredefaultpowerschemes
|
|
441
|
+
public static PowerRestoreDefaultPowerSchemes(): DWORD {
|
|
442
|
+
return PowrProf.Load('PowerRestoreDefaultPowerSchemes')();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerrestoreindividualdefaultpowerscheme
|
|
446
|
+
public static PowerRestoreIndividualDefaultPowerScheme(SchemeGuid: LPCGUID): DWORD {
|
|
447
|
+
return PowrProf.Load('PowerRestoreIndividualDefaultPowerScheme')(SchemeGuid);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powersetactivescheme
|
|
451
|
+
public static PowerSetActiveScheme(UserRootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID): DWORD {
|
|
452
|
+
return PowrProf.Load('PowerSetActiveScheme')(UserRootPowerKey, SchemeGuid);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powersetuserconfiguredacpowermode
|
|
456
|
+
public static PowerSetUserConfiguredACPowerMode(PowerModeGuid: LPCGUID): DWORD {
|
|
457
|
+
return PowrProf.Load('PowerSetUserConfiguredACPowerMode')(PowerModeGuid);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powersetuserconfigureddcpowermode
|
|
461
|
+
public static PowerSetUserConfiguredDCPowerMode(PowerModeGuid: LPCGUID): DWORD {
|
|
462
|
+
return PowrProf.Load('PowerSetUserConfiguredDCPowerMode')(PowerModeGuid);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powersettingaccesscheck
|
|
466
|
+
public static PowerSettingAccessCheck(AccessFlags: POWER_DATA_ACCESSOR, PowerGuid: LPCGUID | NULL): DWORD {
|
|
467
|
+
return PowrProf.Load('PowerSettingAccessCheck')(AccessFlags, PowerGuid);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powersettingaccesscheckex
|
|
471
|
+
public static PowerSettingAccessCheckEx(AccessFlags: POWER_DATA_ACCESSOR, PowerGuid: LPCGUID | NULL, AccessType: REGSAM): DWORD {
|
|
472
|
+
return PowrProf.Load('PowerSettingAccessCheckEx')(AccessFlags, PowerGuid, AccessType);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powersettingregisternotification
|
|
476
|
+
public static PowerSettingRegisterNotification(SettingGuid: LPCGUID, Flags: DWORD, Recipient: HANDLE, RegistrationHandle: PHPOWERNOTIFY): DWORD {
|
|
477
|
+
return PowrProf.Load('PowerSettingRegisterNotification')(SettingGuid, Flags, Recipient, RegistrationHandle);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powersettingunregisternotification
|
|
481
|
+
public static PowerSettingUnregisterNotification(RegistrationHandle: HPOWERNOTIFY): DWORD {
|
|
482
|
+
return PowrProf.Load('PowerSettingUnregisterNotification')(RegistrationHandle);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerunregisterfromeffectivepowermodenotifications
|
|
486
|
+
public static PowerUnregisterFromEffectivePowerModeNotifications(RegistrationHandle: HPOWERNOTIFY): HRESULT {
|
|
487
|
+
return PowrProf.Load('PowerUnregisterFromEffectivePowerModeNotifications')(RegistrationHandle);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-powerunregistersuspendresumenotification
|
|
491
|
+
public static PowerUnregisterSuspendResumeNotification(RegistrationHandle: HPOWERNOTIFY): DWORD {
|
|
492
|
+
return PowrProf.Load('PowerUnregisterSuspendResumeNotification')(RegistrationHandle);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwriteacdefaultindex
|
|
496
|
+
public static PowerWriteACDefaultIndex(RootSystemPowerKey: HKEY | 0n, SchemePersonalityGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID, DefaultAcIndex: DWORD): DWORD {
|
|
497
|
+
return PowrProf.Load('PowerWriteACDefaultIndex')(RootSystemPowerKey, SchemePersonalityGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DefaultAcIndex);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerwriteacvalueindex
|
|
501
|
+
public static PowerWriteACValueIndex(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, AcValueIndex: DWORD): DWORD {
|
|
502
|
+
return PowrProf.Load('PowerWriteACValueIndex')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, AcValueIndex);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritedcdefaultindex
|
|
506
|
+
public static PowerWriteDCDefaultIndex(RootSystemPowerKey: HKEY | 0n, SchemePersonalityGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID, DefaultDcIndex: DWORD): DWORD {
|
|
507
|
+
return PowrProf.Load('PowerWriteDCDefaultIndex')(RootSystemPowerKey, SchemePersonalityGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DefaultDcIndex);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerwritedcvalueindex
|
|
511
|
+
public static PowerWriteDCValueIndex(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, DcValueIndex: DWORD): DWORD {
|
|
512
|
+
return PowrProf.Load('PowerWriteDCValueIndex')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritedescription
|
|
516
|
+
public static PowerWriteDescription(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
517
|
+
return PowrProf.Load('PowerWriteDescription')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritefriendlyname
|
|
521
|
+
public static PowerWriteFriendlyName(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
522
|
+
return PowrProf.Load('PowerWriteFriendlyName')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwriteiconresourcespecifier
|
|
526
|
+
public static PowerWriteIconResourceSpecifier(RootPowerKey: HKEY | 0n, SchemeGuid: LPCGUID, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
527
|
+
return PowrProf.Load('PowerWriteIconResourceSpecifier')(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritepossibledescription
|
|
531
|
+
public static PowerWritePossibleDescription(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, PossibleSettingIndex: ULONG, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
532
|
+
return PowrProf.Load('PowerWritePossibleDescription')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, PossibleSettingIndex, Buffer, BufferSize);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritepossiblefriendlyname
|
|
536
|
+
public static PowerWritePossibleFriendlyName(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, PossibleSettingIndex: ULONG, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
537
|
+
return PowrProf.Load('PowerWritePossibleFriendlyName')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, PossibleSettingIndex, Buffer, BufferSize);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritepossiblevalue
|
|
541
|
+
public static PowerWritePossibleValue(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Type: ULONG, PossibleSettingIndex: ULONG, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
542
|
+
return PowrProf.Load('PowerWritePossibleValue')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Type, PossibleSettingIndex, Buffer, BufferSize);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritesettingattributes
|
|
546
|
+
public static PowerWriteSettingAttributes(SubGroupGuid: LPCGUID, PowerSettingGuid: LPCGUID | NULL, Attributes: DWORD): DWORD {
|
|
547
|
+
return PowrProf.Load('PowerWriteSettingAttributes')(SubGroupGuid, PowerSettingGuid, Attributes);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritevalueincrement
|
|
551
|
+
public static PowerWriteValueIncrement(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueIncrement: DWORD): DWORD {
|
|
552
|
+
return PowrProf.Load('PowerWriteValueIncrement')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueIncrement);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritevaluemax
|
|
556
|
+
public static PowerWriteValueMax(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueMaximum: DWORD): DWORD {
|
|
557
|
+
return PowrProf.Load('PowerWriteValueMax')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueMaximum);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritevaluemin
|
|
561
|
+
public static PowerWriteValueMin(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, ValueMinimum: DWORD): DWORD {
|
|
562
|
+
return PowrProf.Load('PowerWriteValueMin')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, ValueMinimum);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-powerwritevalueunitsspecifier
|
|
566
|
+
public static PowerWriteValueUnitsSpecifier(RootPowerKey: HKEY | 0n, SubGroupOfPowerSettingsGuid: LPCGUID | NULL, PowerSettingGuid: LPCGUID | NULL, Buffer: PUCHAR, BufferSize: DWORD): DWORD {
|
|
567
|
+
return PowrProf.Load('PowerWriteValueUnitsSpecifier')(RootPowerKey, SubGroupOfPowerSettingsGuid, PowerSettingGuid, Buffer, BufferSize);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-readglobalpwrpolicy
|
|
571
|
+
public static ReadGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): BOOLEAN {
|
|
572
|
+
return PowrProf.Load('ReadGlobalPwrPolicy')(pGlobalPowerPolicy);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-readprocessorpwrscheme
|
|
576
|
+
public static ReadProcessorPwrScheme(uiID: UINT, pMachineProcessorPowerPolicy: PMACHINE_PROCESSOR_POWER_POLICY): BOOLEAN {
|
|
577
|
+
return PowrProf.Load('ReadProcessorPwrScheme')(uiID, pMachineProcessorPowerPolicy);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-readpwrscheme
|
|
581
|
+
public static ReadPwrScheme(uiID: UINT, pPowerPolicy: PPOWER_POLICY): BOOLEAN {
|
|
582
|
+
return PowrProf.Load('ReadPwrScheme')(uiID, pPowerPolicy);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-setactivepwrscheme
|
|
586
|
+
public static SetActivePwrScheme(uiID: UINT, pGlobalPowerPolicy: PGLOBAL_POWER_POLICY | NULL, pPowerPolicy: PPOWER_POLICY | NULL): BOOLEAN {
|
|
587
|
+
return PowrProf.Load('SetActivePwrScheme')(uiID, pGlobalPowerPolicy, pPowerPolicy);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-setsuspendstate
|
|
591
|
+
public static SetSuspendState(bHibernate: BOOLEAN, bForce: BOOLEAN, bWakeupEventsDisabled: BOOLEAN): BOOLEAN {
|
|
592
|
+
return PowrProf.Load('SetSuspendState')(bHibernate, bForce, bWakeupEventsDisabled);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-validatepowerpolicies
|
|
596
|
+
public static ValidatePowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY, pPowerPolicy: PPOWER_POLICY): BOOLEAN {
|
|
597
|
+
return PowrProf.Load('ValidatePowerPolicies')(pGlobalPowerPolicy, pPowerPolicy);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-writeglobalpwrpolicy
|
|
601
|
+
public static WriteGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): BOOLEAN {
|
|
602
|
+
return PowrProf.Load('WriteGlobalPwrPolicy')(pGlobalPowerPolicy);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-writeprocessorpwrscheme
|
|
606
|
+
public static WriteProcessorPwrScheme(uiID: UINT, pMachineProcessorPowerPolicy: PMACHINE_PROCESSOR_POWER_POLICY): BOOLEAN {
|
|
607
|
+
return PowrProf.Load('WriteProcessorPwrScheme')(uiID, pMachineProcessorPowerPolicy);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-writepwrscheme
|
|
611
|
+
public static WritePwrScheme(puiID: PUINT, lpszSchemeName: LPCWSTR, lpszDescription: LPCWSTR | NULL, lpScheme: PPOWER_POLICY): BOOLEAN {
|
|
612
|
+
return PowrProf.Load('WritePwrScheme')(puiID, lpszSchemeName, lpszDescription, lpScheme);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export default PowrProf;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Pointer } from 'bun:ffi';
|
|
2
|
+
|
|
3
|
+
export type { BOOL, BOOLEAN, DWORD, HANDLE, HRESULT, LPARAM, LPBYTE, LPCWSTR, LPDWORD, NULL, PBYTE, PULONG, PVOID, UINT, ULONG } from '@bun-win32/core';
|
|
4
|
+
|
|
5
|
+
export const NO_SUBGROUP_GUID = Buffer.from([0x3e, 0x41, 0xa3, 0xfe, 0x05, 0x7e, 0x11, 0x49, 0x9a, 0x71, 0x70, 0x03, 0x31, 0xf1, 0xc2, 0x94]);
|
|
6
|
+
|
|
7
|
+
export enum POWER_DATA_ACCESSOR {
|
|
8
|
+
ACCESS_AC_POWER_SETTING_INDEX = 0x00,
|
|
9
|
+
ACCESS_AC_POWER_SETTING_MAX = 0x15,
|
|
10
|
+
ACCESS_AC_POWER_SETTING_MIN = 0x17,
|
|
11
|
+
ACCESS_ACTIVE_OVERLAY_SCHEME = 0x1b,
|
|
12
|
+
ACCESS_ACTIVE_SCHEME = 0x13,
|
|
13
|
+
ACCESS_ATTRIBUTES = 0x0f,
|
|
14
|
+
ACCESS_CREATE_SCHEME = 0x14,
|
|
15
|
+
ACCESS_DC_POWER_SETTING_INDEX = 0x01,
|
|
16
|
+
ACCESS_DC_POWER_SETTING_MAX = 0x16,
|
|
17
|
+
ACCESS_DC_POWER_SETTING_MIN = 0x18,
|
|
18
|
+
ACCESS_DEFAULT_AC_POWER_SETTING = 0x07,
|
|
19
|
+
ACCESS_DEFAULT_DC_POWER_SETTING = 0x08,
|
|
20
|
+
ACCESS_DEFAULT_SECURITY_DESCRIPTOR = 0x0e,
|
|
21
|
+
ACCESS_DESCRIPTION = 0x03,
|
|
22
|
+
ACCESS_FRIENDLY_NAME = 0x02,
|
|
23
|
+
ACCESS_ICON_RESOURCE = 0x0d,
|
|
24
|
+
ACCESS_INDIVIDUAL_SETTING = 0x12,
|
|
25
|
+
ACCESS_OVERLAY_SCHEME = 0x1a,
|
|
26
|
+
ACCESS_POSSIBLE_POWER_SETTING = 0x04,
|
|
27
|
+
ACCESS_POSSIBLE_POWER_SETTING_DESCRIPTION = 0x06,
|
|
28
|
+
ACCESS_POSSIBLE_POWER_SETTING_FRIENDLY_NAME = 0x05,
|
|
29
|
+
ACCESS_POSSIBLE_VALUE_INCREMENT = 0x0b,
|
|
30
|
+
ACCESS_POSSIBLE_VALUE_MAX = 0x0a,
|
|
31
|
+
ACCESS_POSSIBLE_VALUE_MIN = 0x09,
|
|
32
|
+
ACCESS_POSSIBLE_VALUE_UNITS = 0x0c,
|
|
33
|
+
ACCESS_PROFILE = 0x19,
|
|
34
|
+
ACCESS_SCHEME = 0x10,
|
|
35
|
+
ACCESS_SUBGROUP = 0x11,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export enum POWER_INFORMATION_LEVEL {
|
|
39
|
+
AdministratorPowerPolicy = 0x09,
|
|
40
|
+
LastSleepTime = 0x0f,
|
|
41
|
+
LastWakeTime = 0x0e,
|
|
42
|
+
MonitorCapabilities = 0x29,
|
|
43
|
+
MonitorInvocation = 0x28,
|
|
44
|
+
NotifyUserPowerSetting = 0x1a,
|
|
45
|
+
PowerInformationLevelUnused0 = 0x1b,
|
|
46
|
+
PowerShutdownNotification = 0x27,
|
|
47
|
+
ProcessorCap = 0x22,
|
|
48
|
+
ProcessorIdleStates = 0x21,
|
|
49
|
+
ProcessorInformation = 0x0b,
|
|
50
|
+
ProcessorLoad = 0x26,
|
|
51
|
+
ProcessorPerfStates = 0x20,
|
|
52
|
+
ProcessorPowerPolicyAc = 0x12,
|
|
53
|
+
ProcessorPowerPolicyCurrent = 0x16,
|
|
54
|
+
ProcessorPowerPolicyDc = 0x13,
|
|
55
|
+
ProcessorStateHandler = 0x07,
|
|
56
|
+
ProcessorStateHandler2 = 0x0d,
|
|
57
|
+
SetPowerSettingValue = 0x19,
|
|
58
|
+
SystemBatteryState = 0x05,
|
|
59
|
+
SystemExecutionState = 0x10,
|
|
60
|
+
SystemHiberFileInformation = 0x24,
|
|
61
|
+
SystemMonitorHiberBootPowerOff = 0x1c,
|
|
62
|
+
SystemPowerCapabilities = 0x04,
|
|
63
|
+
SystemPowerInformation = 0x0c,
|
|
64
|
+
SystemPowerLoggingEntry = 0x18,
|
|
65
|
+
SystemPowerPolicyAc = 0x00,
|
|
66
|
+
SystemPowerPolicyCurrent = 0x08,
|
|
67
|
+
SystemPowerPolicyDc = 0x01,
|
|
68
|
+
SystemPowerStateHandler = 0x06,
|
|
69
|
+
SystemPowerStateLogging = 0x17,
|
|
70
|
+
SystemPowerStateNotifyHandler = 0x11,
|
|
71
|
+
SystemReserveHiberFile = 0x0a,
|
|
72
|
+
SystemVideoState = 0x1d,
|
|
73
|
+
SystemWakeSource = 0x23,
|
|
74
|
+
TraceApplicationPowerMessage = 0x1e,
|
|
75
|
+
TraceApplicationPowerMessageEnd = 0x1f,
|
|
76
|
+
TraceServicePowerMessage = 0x25,
|
|
77
|
+
VerifyProcessorPowerPolicyAc = 0x14,
|
|
78
|
+
VerifyProcessorPowerPolicyDc = 0x15,
|
|
79
|
+
VerifySystemPolicyAc = 0x02,
|
|
80
|
+
VerifySystemPolicyDc = 0x03,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export enum POWER_PLATFORM_ROLE {
|
|
84
|
+
PlatformRoleAppliancePC = 0x06,
|
|
85
|
+
PlatformRoleDesktop = 0x01,
|
|
86
|
+
PlatformRoleEnterpriseServer = 0x04,
|
|
87
|
+
PlatformRoleMaximum = 0x09,
|
|
88
|
+
PlatformRoleMobile = 0x02,
|
|
89
|
+
PlatformRolePerformanceServer = 0x07,
|
|
90
|
+
PlatformRoleSlate = 0x08,
|
|
91
|
+
PlatformRoleSOHOServer = 0x05,
|
|
92
|
+
PlatformRoleUnspecified = 0x00,
|
|
93
|
+
PlatformRoleWorkstation = 0x03,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type EFFECTIVE_POWER_MODE_CALLBACK = Pointer;
|
|
97
|
+
export type HKEY = bigint;
|
|
98
|
+
export type HPOWERNOTIFY = bigint;
|
|
99
|
+
export type LPCGUID = Pointer;
|
|
100
|
+
export type LPGUID = Pointer;
|
|
101
|
+
export type NTSTATUS = number;
|
|
102
|
+
export type PADMINISTRATOR_POWER_POLICY = Pointer;
|
|
103
|
+
export type PGLOBAL_POWER_POLICY = Pointer;
|
|
104
|
+
export type PHPOWERNOTIFY = Pointer;
|
|
105
|
+
export type PMACHINE_PROCESSOR_POWER_POLICY = Pointer;
|
|
106
|
+
export type PPOWER_POLICY = Pointer;
|
|
107
|
+
export type PSYSTEM_POWER_CAPABILITIES = Pointer;
|
|
108
|
+
export type PTHERMAL_EVENT = Pointer;
|
|
109
|
+
export type PUCHAR = Pointer;
|
|
110
|
+
export type PUINT = Pointer;
|
|
111
|
+
export type PWRSCHEMESENUMPROC = Pointer;
|
|
112
|
+
export type REGSAM = number;
|