Win32 API 日本語リファレンス
ホームSystem.Power › CallNtPowerInformation

CallNtPowerInformation

関数
電源情報の取得や電源設定の変更を行う。
DLLPOWRPROF.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// POWRPROF.dll
#include <windows.h>

NTSTATUS CallNtPowerInformation(
    POWER_INFORMATION_LEVEL InformationLevel,
    void* InputBuffer,   // optional
    DWORD InputBufferLength,
    void* OutputBuffer,   // optional
    DWORD OutputBufferLength
);

パラメーター

名前方向説明
InformationLevelPOWER_INFORMATION_LEVELin

要求する情報レベル。この値は、設定または取得する具体的な電源情報を示します。このパラメーターは、次の POWER_INFORMATION_LEVEL 列挙型の値のいずれかでなければなりません。

意味
AdministratorPowerPolicy
9
この情報レベルはサポートされていません。
LastSleepTime
15
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、最後にシステムがスリープした時刻における割り込み時間カウントを 100 ナノ秒単位で示す ULONGLONG が格納されます。

LastWakeTime
14
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、最後にシステムが復帰した時刻における割り込み時間カウントを 100 ナノ秒単位で示す ULONGLONG が格納されます。

ProcessorInformation
11
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、システムに搭載されている各プロセッサーごとに 1 つの PROCESSOR_POWER_INFORMATION 構造体が格納されます。プロセッサーの数を取得するには、GetSystemInfo 関数を使用します。

ProcessorPowerPolicyAc
18
この情報レベルはサポートされていません。
ProcessorPowerPolicyCurrent
22
この情報レベルはサポートされていません。
ProcessorPowerPolicyDc
19
この情報レベルはサポートされていません。
SystemBatteryState
5
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、現在のシステムバッテリーに関する情報を含む SYSTEM_BATTERY_STATE 構造体 が格納されます。

SystemExecutionState
16
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、システムの実行状態を含む ULONG 値が格納されます。この値には、次の値の任意の組み合わせを含めることができます。 ES_SYSTEM_REQUIREDES_DISPLAY_REQUIRED、または ES_USER_PRESENT。詳細については、 SetThreadExecutionState 関数を参照してください。

SystemPowerCapabilities
4
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、現在のシステム電源機能を含む SYSTEM_POWER_CAPABILITIES 構造体が格納されます。

この情報は、現在サポートされている電源機能を表します。これは、システムにドライバーがインストールされると変化する可能性があります。たとえば、電源管理をサポートしないレガシーデバイスドライバーをインストールすると、システムのすべてのスリープ状態が無効になります。

SystemPowerInformation
12
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、 SYSTEM_POWER_INFORMATION 構造体が格納されます。

アプリケーションはこのレベルを使用して、システムのアイドル状態に関する情報を取得できます。

SystemPowerPolicyAc
0
lpInBufferNULL でない場合、関数は lpInBuffer に渡された SYSTEM_POWER_POLICY の値を、 システムが AC (商用) 電源で動作しているときに使用される現在のシステム電源ポリシーに適用します。

lpOutputBuffer バッファーには、システムが AC (商用) 電源で動作しているときに使用される現在のシステム電源ポリシーを含む SYSTEM_POWER_POLICY 構造体が格納されます。

SystemPowerPolicyCurrent
8
lpInBuffer パラメーターは NULL でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER を返します。

lpOutputBuffer バッファーには、システムが AC (商用) 電源で動作しているときに使用される現在のシステム電源ポリシーを含む SYSTEM_POWER_POLICY 構造体が格納されます。

SystemPowerPolicyDc
1
lpInBufferNULL でない場合、関数は lpInBuffer に渡された SYSTEM_POWER_POLICY の値を、 システムがバッテリー電源で動作しているときに使用される現在のシステム電源ポリシーに適用します。

lpOutputBuffer バッファーには、システムがバッテリー電源で動作しているときに使用される現在のシステム電源ポリシーを含む SYSTEM_POWER_POLICY 構造体が格納されます。

SystemReserveHiberFile
10
lpInBufferNULL でなく、現在のユーザーが十分な権限を持っている場合、関数はブートボリューム上にハイバネーションイメージを保持するために必要なストレージをコミットまたはデコミットします。

lpInBuffer パラメーターは、要求の内容を示す BOOLEAN 値を指す必要があります。値が TRUE の場合はハイバネーションファイルが予約され、値が FALSE の場合はハイバネーションファイルが削除されます。

VerifyProcessorPowerPolicyAc
20
この情報レベルはサポートされていません。
VerifyProcessorPowerPolicyDc
21
この情報レベルはサポートされていません。
VerifySystemPolicyAc
2
この情報レベルはサポートされていません。
VerifySystemPolicyDc
3
この情報レベルはサポートされていません。
InputBuffervoid*inoptional省略可能な入力バッファーへのポインター。このバッファーのデータ型は、InformationLevel パラメーターで要求された情報レベルによって異なります。
InputBufferLengthDWORDin入力バッファーのサイズ (バイト単位)。
OutputBuffervoid*outoptional省略可能な出力バッファーへのポインター。このバッファーのデータ型は、InformationLevel パラメーターで要求された情報レベルによって異なります。バッファーが情報を格納するには小さすぎる場合、関数は STATUS_BUFFER_TOO_SMALL を返します。
OutputBufferLengthDWORDin出力バッファーのサイズ (バイト単位)。要求された情報レベルによっては、可変サイズのバッファーになる場合があります。

戻り値の型: NTSTATUS

公式ドキュメント

電源情報を設定または取得します。

戻り値

関数が成功した場合、戻り値は STATUS_SUCCESS です。

関数が失敗した場合、戻り値は次のいずれかのステータスコードになります。

ステータス 意味
STATUS_BUFFER_TOO_SMALL
出力バッファーのサイズが、返されるデータを格納するには不十分です。
STATUS_ACCESS_DENIED
呼び出し元に、要求された操作を実行するための十分なアクセス権がありませんでした。

解説(Remarks)

CallNtPowerInformation を使用して現在のシステム電源ポリシーに加えた変更は即座に反映されますが、永続的ではありません。つまり、変更は電源スキームの一部として保存されません。CallNtPowerInformation によって行われたシステム電源ポリシーへの変更は、ユーザーが電源オプションのコントロールパネルプログラムでポリシースキームに加えた変更や、その後の WritePwrSchemeSetActivePwrScheme などの電源スキーム関数の呼び出しによって上書きされる場合があります。

PowrProf.h の使用方法の詳細については、電源スキーム を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// POWRPROF.dll
#include <windows.h>

NTSTATUS CallNtPowerInformation(
    POWER_INFORMATION_LEVEL InformationLevel,
    void* InputBuffer,   // optional
    DWORD InputBufferLength,
    void* OutputBuffer,   // optional
    DWORD OutputBufferLength
);
[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern int CallNtPowerInformation(
    int InformationLevel,   // POWER_INFORMATION_LEVEL
    IntPtr InputBuffer,   // void* optional
    uint InputBufferLength,   // DWORD
    IntPtr OutputBuffer,   // void* optional, out
    uint OutputBufferLength   // DWORD
);
<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function CallNtPowerInformation(
    InformationLevel As Integer,   ' POWER_INFORMATION_LEVEL
    InputBuffer As IntPtr,   ' void* optional
    InputBufferLength As UInteger,   ' DWORD
    OutputBuffer As IntPtr,   ' void* optional, out
    OutputBufferLength As UInteger   ' DWORD
) As Integer
End Function
' InformationLevel : POWER_INFORMATION_LEVEL
' InputBuffer : void* optional
' InputBufferLength : DWORD
' OutputBuffer : void* optional, out
' OutputBufferLength : DWORD
Declare PtrSafe Function CallNtPowerInformation Lib "powrprof" ( _
    ByVal InformationLevel As Long, _
    ByVal InputBuffer As LongPtr, _
    ByVal InputBufferLength As Long, _
    ByVal OutputBuffer As LongPtr, _
    ByVal OutputBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CallNtPowerInformation = ctypes.windll.powrprof.CallNtPowerInformation
CallNtPowerInformation.restype = ctypes.c_int
CallNtPowerInformation.argtypes = [
    ctypes.c_int,  # InformationLevel : POWER_INFORMATION_LEVEL
    ctypes.POINTER(None),  # InputBuffer : void* optional
    wintypes.DWORD,  # InputBufferLength : DWORD
    ctypes.POINTER(None),  # OutputBuffer : void* optional, out
    wintypes.DWORD,  # OutputBufferLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('POWRPROF.dll')
CallNtPowerInformation = Fiddle::Function.new(
  lib['CallNtPowerInformation'],
  [
    Fiddle::TYPE_INT,  # InformationLevel : POWER_INFORMATION_LEVEL
    Fiddle::TYPE_VOIDP,  # InputBuffer : void* optional
    -Fiddle::TYPE_INT,  # InputBufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # OutputBuffer : void* optional, out
    -Fiddle::TYPE_INT,  # OutputBufferLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "powrprof")]
extern "system" {
    fn CallNtPowerInformation(
        InformationLevel: i32,  // POWER_INFORMATION_LEVEL
        InputBuffer: *mut (),  // void* optional
        InputBufferLength: u32,  // DWORD
        OutputBuffer: *mut (),  // void* optional, out
        OutputBufferLength: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("POWRPROF.dll")]
public static extern int CallNtPowerInformation(int InformationLevel, IntPtr InputBuffer, uint InputBufferLength, IntPtr OutputBuffer, uint OutputBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'POWRPROF_CallNtPowerInformation' -Namespace Win32 -PassThru
# $api::CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
#uselib "POWRPROF.dll"
#func global CallNtPowerInformation "CallNtPowerInformation" sptr, sptr, sptr, sptr, sptr
; CallNtPowerInformation InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength   ; 戻り値は stat
; InformationLevel : POWER_INFORMATION_LEVEL -> "sptr"
; InputBuffer : void* optional -> "sptr"
; InputBufferLength : DWORD -> "sptr"
; OutputBuffer : void* optional, out -> "sptr"
; OutputBufferLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "POWRPROF.dll"
#cfunc global CallNtPowerInformation "CallNtPowerInformation" int, sptr, int, sptr, int
; res = CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
; InformationLevel : POWER_INFORMATION_LEVEL -> "int"
; InputBuffer : void* optional -> "sptr"
; InputBufferLength : DWORD -> "int"
; OutputBuffer : void* optional, out -> "sptr"
; OutputBufferLength : DWORD -> "int"
; NTSTATUS CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, void* InputBuffer, DWORD InputBufferLength, void* OutputBuffer, DWORD OutputBufferLength)
#uselib "POWRPROF.dll"
#cfunc global CallNtPowerInformation "CallNtPowerInformation" int, intptr, int, intptr, int
; res = CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
; InformationLevel : POWER_INFORMATION_LEVEL -> "int"
; InputBuffer : void* optional -> "intptr"
; InputBufferLength : DWORD -> "int"
; OutputBuffer : void* optional, out -> "intptr"
; OutputBufferLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
	procCallNtPowerInformation = powrprof.NewProc("CallNtPowerInformation")
)

// InformationLevel (POWER_INFORMATION_LEVEL), InputBuffer (void* optional), InputBufferLength (DWORD), OutputBuffer (void* optional, out), OutputBufferLength (DWORD)
r1, _, err := procCallNtPowerInformation.Call(
	uintptr(InformationLevel),
	uintptr(InputBuffer),
	uintptr(InputBufferLength),
	uintptr(OutputBuffer),
	uintptr(OutputBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function CallNtPowerInformation(
  InformationLevel: Integer;   // POWER_INFORMATION_LEVEL
  InputBuffer: Pointer;   // void* optional
  InputBufferLength: DWORD;   // DWORD
  OutputBuffer: Pointer;   // void* optional, out
  OutputBufferLength: DWORD   // DWORD
): Integer; stdcall;
  external 'POWRPROF.dll' name 'CallNtPowerInformation';
result := DllCall("POWRPROF\CallNtPowerInformation"
    , "Int", InformationLevel   ; POWER_INFORMATION_LEVEL
    , "Ptr", InputBuffer   ; void* optional
    , "UInt", InputBufferLength   ; DWORD
    , "Ptr", OutputBuffer   ; void* optional, out
    , "UInt", OutputBufferLength   ; DWORD
    , "Int")   ; return: NTSTATUS
●CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength) = DLL("POWRPROF.dll", "int CallNtPowerInformation(int, void*, dword, void*, dword)")
# 呼び出し: CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
# InformationLevel : POWER_INFORMATION_LEVEL -> "int"
# InputBuffer : void* optional -> "void*"
# InputBufferLength : DWORD -> "dword"
# OutputBuffer : void* optional, out -> "void*"
# OutputBufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "powrprof" fn CallNtPowerInformation(
    InformationLevel: i32, // POWER_INFORMATION_LEVEL
    InputBuffer: ?*anyopaque, // void* optional
    InputBufferLength: u32, // DWORD
    OutputBuffer: ?*anyopaque, // void* optional, out
    OutputBufferLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc CallNtPowerInformation(
    InformationLevel: int32,  # POWER_INFORMATION_LEVEL
    InputBuffer: pointer,  # void* optional
    InputBufferLength: uint32,  # DWORD
    OutputBuffer: pointer,  # void* optional, out
    OutputBufferLength: uint32  # DWORD
): int32 {.importc: "CallNtPowerInformation", stdcall, dynlib: "POWRPROF.dll".}
pragma(lib, "powrprof");
extern(Windows)
int CallNtPowerInformation(
    int InformationLevel,   // POWER_INFORMATION_LEVEL
    void* InputBuffer,   // void* optional
    uint InputBufferLength,   // DWORD
    void* OutputBuffer,   // void* optional, out
    uint OutputBufferLength   // DWORD
);
ccall((:CallNtPowerInformation, "POWRPROF.dll"), stdcall, Int32,
      (Int32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32),
      InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
# InformationLevel : POWER_INFORMATION_LEVEL -> Int32
# InputBuffer : void* optional -> Ptr{Cvoid}
# InputBufferLength : DWORD -> UInt32
# OutputBuffer : void* optional, out -> Ptr{Cvoid}
# OutputBufferLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CallNtPowerInformation(
    int32_t InformationLevel,
    void* InputBuffer,
    uint32_t InputBufferLength,
    void* OutputBuffer,
    uint32_t OutputBufferLength);
]]
local powrprof = ffi.load("powrprof")
-- powrprof.CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
-- InformationLevel : POWER_INFORMATION_LEVEL
-- InputBuffer : void* optional
-- InputBufferLength : DWORD
-- OutputBuffer : void* optional, out
-- OutputBufferLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('POWRPROF.dll');
const CallNtPowerInformation = lib.func('__stdcall', 'CallNtPowerInformation', 'int32_t', ['int32_t', 'void *', 'uint32_t', 'void *', 'uint32_t']);
// CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
// InformationLevel : POWER_INFORMATION_LEVEL -> 'int32_t'
// InputBuffer : void* optional -> 'void *'
// InputBufferLength : DWORD -> 'uint32_t'
// OutputBuffer : void* optional, out -> 'void *'
// OutputBufferLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("POWRPROF.dll", {
  CallNtPowerInformation: { parameters: ["i32", "pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength)
// InformationLevel : POWER_INFORMATION_LEVEL -> "i32"
// InputBuffer : void* optional -> "pointer"
// InputBufferLength : DWORD -> "u32"
// OutputBuffer : void* optional, out -> "pointer"
// OutputBufferLength : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CallNtPowerInformation(
    int32_t InformationLevel,
    void* InputBuffer,
    uint32_t InputBufferLength,
    void* OutputBuffer,
    uint32_t OutputBufferLength);
C, "POWRPROF.dll");
// $ffi->CallNtPowerInformation(InformationLevel, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength);
// InformationLevel : POWER_INFORMATION_LEVEL
// InputBuffer : void* optional
// InputBufferLength : DWORD
// OutputBuffer : void* optional, out
// OutputBufferLength : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Powrprof extends StdCallLibrary {
    Powrprof INSTANCE = Native.load("powrprof", Powrprof.class);
    int CallNtPowerInformation(
        int InformationLevel,   // POWER_INFORMATION_LEVEL
        Pointer InputBuffer,   // void* optional
        int InputBufferLength,   // DWORD
        Pointer OutputBuffer,   // void* optional, out
        int OutputBufferLength   // DWORD
    );
}
@[Link("powrprof")]
lib LibPOWRPROF
  fun CallNtPowerInformation = CallNtPowerInformation(
    InformationLevel : Int32,   # POWER_INFORMATION_LEVEL
    InputBuffer : Void*,   # void* optional
    InputBufferLength : UInt32,   # DWORD
    OutputBuffer : Void*,   # void* optional, out
    OutputBufferLength : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CallNtPowerInformationNative = Int32 Function(Int32, Pointer<Void>, Uint32, Pointer<Void>, Uint32);
typedef CallNtPowerInformationDart = int Function(int, Pointer<Void>, int, Pointer<Void>, int);
final CallNtPowerInformation = DynamicLibrary.open('POWRPROF.dll')
    .lookupFunction<CallNtPowerInformationNative, CallNtPowerInformationDart>('CallNtPowerInformation');
// InformationLevel : POWER_INFORMATION_LEVEL -> Int32
// InputBuffer : void* optional -> Pointer<Void>
// InputBufferLength : DWORD -> Uint32
// OutputBuffer : void* optional, out -> Pointer<Void>
// OutputBufferLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CallNtPowerInformation(
  InformationLevel: Integer;   // POWER_INFORMATION_LEVEL
  InputBuffer: Pointer;   // void* optional
  InputBufferLength: DWORD;   // DWORD
  OutputBuffer: Pointer;   // void* optional, out
  OutputBufferLength: DWORD   // DWORD
): Integer; stdcall;
  external 'POWRPROF.dll' name 'CallNtPowerInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CallNtPowerInformation"
  c_CallNtPowerInformation :: Int32 -> Ptr () -> Word32 -> Ptr () -> Word32 -> IO Int32
-- InformationLevel : POWER_INFORMATION_LEVEL -> Int32
-- InputBuffer : void* optional -> Ptr ()
-- InputBufferLength : DWORD -> Word32
-- OutputBuffer : void* optional, out -> Ptr ()
-- OutputBufferLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let callntpowerinformation =
  foreign "CallNtPowerInformation"
    (int32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* InformationLevel : POWER_INFORMATION_LEVEL -> int32_t *)
(* InputBuffer : void* optional -> (ptr void) *)
(* InputBufferLength : DWORD -> uint32_t *)
(* OutputBuffer : void* optional, out -> (ptr void) *)
(* OutputBufferLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library powrprof (t "POWRPROF.dll"))
(cffi:use-foreign-library powrprof)

(cffi:defcfun ("CallNtPowerInformation" call-nt-power-information :convention :stdcall) :int32
  (information-level :int32)   ; POWER_INFORMATION_LEVEL
  (input-buffer :pointer)   ; void* optional
  (input-buffer-length :uint32)   ; DWORD
  (output-buffer :pointer)   ; void* optional, out
  (output-buffer-length :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CallNtPowerInformation = Win32::API::More->new('POWRPROF',
    'int CallNtPowerInformation(int InformationLevel, LPVOID InputBuffer, DWORD InputBufferLength, LPVOID OutputBuffer, DWORD OutputBufferLength)');
# my $ret = $CallNtPowerInformation->Call($InformationLevel, $InputBuffer, $InputBufferLength, $OutputBuffer, $OutputBufferLength);
# InformationLevel : POWER_INFORMATION_LEVEL -> int
# InputBuffer : void* optional -> LPVOID
# InputBufferLength : DWORD -> DWORD
# OutputBuffer : void* optional, out -> LPVOID
# OutputBufferLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型