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

PowerReadDCValueIndex

関数
指定電源設定のDC電源時の値インデックスを読み取る。
DLLPOWRPROF.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD PowerReadDCValueIndex(
    HKEY RootPowerKey,   // optional
    const GUID* SchemeGuid,   // optional
    const GUID* SubGroupOfPowerSettingsGuid,   // optional
    const GUID* PowerSettingGuid,   // optional
    DWORD* DcValueIndex
);

パラメーター

名前方向
RootPowerKeyHKEYinoptional
SchemeGuidGUID*inoptional
SubGroupOfPowerSettingsGuidGUID*inoptional
PowerSettingGuidGUID*inoptional
DcValueIndexDWORD*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PowerReadDCValueIndex(
    HKEY RootPowerKey,   // optional
    const GUID* SchemeGuid,   // optional
    const GUID* SubGroupOfPowerSettingsGuid,   // optional
    const GUID* PowerSettingGuid,   // optional
    DWORD* DcValueIndex
);
[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern uint PowerReadDCValueIndex(
    IntPtr RootPowerKey,   // HKEY optional
    IntPtr SchemeGuid,   // GUID* optional
    IntPtr SubGroupOfPowerSettingsGuid,   // GUID* optional
    IntPtr PowerSettingGuid,   // GUID* optional
    out uint DcValueIndex   // DWORD* out
);
<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function PowerReadDCValueIndex(
    RootPowerKey As IntPtr,   ' HKEY optional
    SchemeGuid As IntPtr,   ' GUID* optional
    SubGroupOfPowerSettingsGuid As IntPtr,   ' GUID* optional
    PowerSettingGuid As IntPtr,   ' GUID* optional
    <Out> ByRef DcValueIndex As UInteger   ' DWORD* out
) As UInteger
End Function
' RootPowerKey : HKEY optional
' SchemeGuid : GUID* optional
' SubGroupOfPowerSettingsGuid : GUID* optional
' PowerSettingGuid : GUID* optional
' DcValueIndex : DWORD* out
Declare PtrSafe Function PowerReadDCValueIndex Lib "powrprof" ( _
    ByVal RootPowerKey As LongPtr, _
    ByVal SchemeGuid As LongPtr, _
    ByVal SubGroupOfPowerSettingsGuid As LongPtr, _
    ByVal PowerSettingGuid As LongPtr, _
    ByRef DcValueIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PowerReadDCValueIndex = ctypes.windll.powrprof.PowerReadDCValueIndex
PowerReadDCValueIndex.restype = wintypes.DWORD
PowerReadDCValueIndex.argtypes = [
    wintypes.HANDLE,  # RootPowerKey : HKEY optional
    ctypes.c_void_p,  # SchemeGuid : GUID* optional
    ctypes.c_void_p,  # SubGroupOfPowerSettingsGuid : GUID* optional
    ctypes.c_void_p,  # PowerSettingGuid : GUID* optional
    ctypes.POINTER(wintypes.DWORD),  # DcValueIndex : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('POWRPROF.dll')
PowerReadDCValueIndex = Fiddle::Function.new(
  lib['PowerReadDCValueIndex'],
  [
    Fiddle::TYPE_VOIDP,  # RootPowerKey : HKEY optional
    Fiddle::TYPE_VOIDP,  # SchemeGuid : GUID* optional
    Fiddle::TYPE_VOIDP,  # SubGroupOfPowerSettingsGuid : GUID* optional
    Fiddle::TYPE_VOIDP,  # PowerSettingGuid : GUID* optional
    Fiddle::TYPE_VOIDP,  # DcValueIndex : DWORD* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "powrprof")]
extern "system" {
    fn PowerReadDCValueIndex(
        RootPowerKey: *mut core::ffi::c_void,  // HKEY optional
        SchemeGuid: *const GUID,  // GUID* optional
        SubGroupOfPowerSettingsGuid: *const GUID,  // GUID* optional
        PowerSettingGuid: *const GUID,  // GUID* optional
        DcValueIndex: *mut u32  // DWORD* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("POWRPROF.dll")]
public static extern uint PowerReadDCValueIndex(IntPtr RootPowerKey, IntPtr SchemeGuid, IntPtr SubGroupOfPowerSettingsGuid, IntPtr PowerSettingGuid, out uint DcValueIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'POWRPROF_PowerReadDCValueIndex' -Namespace Win32 -PassThru
# $api::PowerReadDCValueIndex(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex)
#uselib "POWRPROF.dll"
#func global PowerReadDCValueIndex "PowerReadDCValueIndex" sptr, sptr, sptr, sptr, sptr
; PowerReadDCValueIndex RootPowerKey, varptr(SchemeGuid), varptr(SubGroupOfPowerSettingsGuid), varptr(PowerSettingGuid), varptr(DcValueIndex)   ; 戻り値は stat
; RootPowerKey : HKEY optional -> "sptr"
; SchemeGuid : GUID* optional -> "sptr"
; SubGroupOfPowerSettingsGuid : GUID* optional -> "sptr"
; PowerSettingGuid : GUID* optional -> "sptr"
; DcValueIndex : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "POWRPROF.dll"
#cfunc global PowerReadDCValueIndex "PowerReadDCValueIndex" sptr, var, var, var, var
; res = PowerReadDCValueIndex(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex)
; RootPowerKey : HKEY optional -> "sptr"
; SchemeGuid : GUID* optional -> "var"
; SubGroupOfPowerSettingsGuid : GUID* optional -> "var"
; PowerSettingGuid : GUID* optional -> "var"
; DcValueIndex : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PowerReadDCValueIndex(HKEY RootPowerKey, GUID* SchemeGuid, GUID* SubGroupOfPowerSettingsGuid, GUID* PowerSettingGuid, DWORD* DcValueIndex)
#uselib "POWRPROF.dll"
#cfunc global PowerReadDCValueIndex "PowerReadDCValueIndex" intptr, var, var, var, var
; res = PowerReadDCValueIndex(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex)
; RootPowerKey : HKEY optional -> "intptr"
; SchemeGuid : GUID* optional -> "var"
; SubGroupOfPowerSettingsGuid : GUID* optional -> "var"
; PowerSettingGuid : GUID* optional -> "var"
; DcValueIndex : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
	procPowerReadDCValueIndex = powrprof.NewProc("PowerReadDCValueIndex")
)

// RootPowerKey (HKEY optional), SchemeGuid (GUID* optional), SubGroupOfPowerSettingsGuid (GUID* optional), PowerSettingGuid (GUID* optional), DcValueIndex (DWORD* out)
r1, _, err := procPowerReadDCValueIndex.Call(
	uintptr(RootPowerKey),
	uintptr(SchemeGuid),
	uintptr(SubGroupOfPowerSettingsGuid),
	uintptr(PowerSettingGuid),
	uintptr(DcValueIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PowerReadDCValueIndex(
  RootPowerKey: THandle;   // HKEY optional
  SchemeGuid: PGUID;   // GUID* optional
  SubGroupOfPowerSettingsGuid: PGUID;   // GUID* optional
  PowerSettingGuid: PGUID;   // GUID* optional
  DcValueIndex: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'POWRPROF.dll' name 'PowerReadDCValueIndex';
result := DllCall("POWRPROF\PowerReadDCValueIndex"
    , "Ptr", RootPowerKey   ; HKEY optional
    , "Ptr", SchemeGuid   ; GUID* optional
    , "Ptr", SubGroupOfPowerSettingsGuid   ; GUID* optional
    , "Ptr", PowerSettingGuid   ; GUID* optional
    , "Ptr", DcValueIndex   ; DWORD* out
    , "UInt")   ; return: DWORD
●PowerReadDCValueIndex(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex) = DLL("POWRPROF.dll", "dword PowerReadDCValueIndex(void*, void*, void*, void*, void*)")
# 呼び出し: PowerReadDCValueIndex(RootPowerKey, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, DcValueIndex)
# RootPowerKey : HKEY optional -> "void*"
# SchemeGuid : GUID* optional -> "void*"
# SubGroupOfPowerSettingsGuid : GUID* optional -> "void*"
# PowerSettingGuid : GUID* optional -> "void*"
# DcValueIndex : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。