ホーム › System.Power › PowerOpenSystemPowerKey
PowerOpenSystemPowerKey
関数システムの電源設定レジストリキーを開く。
シグネチャ
// POWRPROF.dll
#include <windows.h>
DWORD PowerOpenSystemPowerKey(
HKEY* phSystemPowerKey,
DWORD Access,
BOOL OpenExisting
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| phSystemPowerKey | HKEY* | out |
| Access | DWORD | in |
| OpenExisting | BOOL | in |
戻り値の型: DWORD
各言語での呼び出し定義
// POWRPROF.dll
#include <windows.h>
DWORD PowerOpenSystemPowerKey(
HKEY* phSystemPowerKey,
DWORD Access,
BOOL OpenExisting
);[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern uint PowerOpenSystemPowerKey(
IntPtr phSystemPowerKey, // HKEY* out
uint Access, // DWORD
bool OpenExisting // BOOL
);<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function PowerOpenSystemPowerKey(
phSystemPowerKey As IntPtr, ' HKEY* out
Access As UInteger, ' DWORD
OpenExisting As Boolean ' BOOL
) As UInteger
End Function' phSystemPowerKey : HKEY* out
' Access : DWORD
' OpenExisting : BOOL
Declare PtrSafe Function PowerOpenSystemPowerKey Lib "powrprof" ( _
ByVal phSystemPowerKey As LongPtr, _
ByVal Access As Long, _
ByVal OpenExisting As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PowerOpenSystemPowerKey = ctypes.windll.powrprof.PowerOpenSystemPowerKey
PowerOpenSystemPowerKey.restype = wintypes.DWORD
PowerOpenSystemPowerKey.argtypes = [
ctypes.c_void_p, # phSystemPowerKey : HKEY* out
wintypes.DWORD, # Access : DWORD
wintypes.BOOL, # OpenExisting : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('POWRPROF.dll')
PowerOpenSystemPowerKey = Fiddle::Function.new(
lib['PowerOpenSystemPowerKey'],
[
Fiddle::TYPE_VOIDP, # phSystemPowerKey : HKEY* out
-Fiddle::TYPE_INT, # Access : DWORD
Fiddle::TYPE_INT, # OpenExisting : BOOL
],
-Fiddle::TYPE_INT)#[link(name = "powrprof")]
extern "system" {
fn PowerOpenSystemPowerKey(
phSystemPowerKey: *mut *mut core::ffi::c_void, // HKEY* out
Access: u32, // DWORD
OpenExisting: i32 // BOOL
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("POWRPROF.dll")]
public static extern uint PowerOpenSystemPowerKey(IntPtr phSystemPowerKey, uint Access, bool OpenExisting);
"@
$api = Add-Type -MemberDefinition $sig -Name 'POWRPROF_PowerOpenSystemPowerKey' -Namespace Win32 -PassThru
# $api::PowerOpenSystemPowerKey(phSystemPowerKey, Access, OpenExisting)#uselib "POWRPROF.dll"
#func global PowerOpenSystemPowerKey "PowerOpenSystemPowerKey" sptr, sptr, sptr
; PowerOpenSystemPowerKey phSystemPowerKey, Access, OpenExisting ; 戻り値は stat
; phSystemPowerKey : HKEY* out -> "sptr"
; Access : DWORD -> "sptr"
; OpenExisting : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "POWRPROF.dll"
#cfunc global PowerOpenSystemPowerKey "PowerOpenSystemPowerKey" sptr, int, int
; res = PowerOpenSystemPowerKey(phSystemPowerKey, Access, OpenExisting)
; phSystemPowerKey : HKEY* out -> "sptr"
; Access : DWORD -> "int"
; OpenExisting : BOOL -> "int"; DWORD PowerOpenSystemPowerKey(HKEY* phSystemPowerKey, DWORD Access, BOOL OpenExisting)
#uselib "POWRPROF.dll"
#cfunc global PowerOpenSystemPowerKey "PowerOpenSystemPowerKey" intptr, int, int
; res = PowerOpenSystemPowerKey(phSystemPowerKey, Access, OpenExisting)
; phSystemPowerKey : HKEY* out -> "intptr"
; Access : DWORD -> "int"
; OpenExisting : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
procPowerOpenSystemPowerKey = powrprof.NewProc("PowerOpenSystemPowerKey")
)
// phSystemPowerKey (HKEY* out), Access (DWORD), OpenExisting (BOOL)
r1, _, err := procPowerOpenSystemPowerKey.Call(
uintptr(phSystemPowerKey),
uintptr(Access),
uintptr(OpenExisting),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PowerOpenSystemPowerKey(
phSystemPowerKey: Pointer; // HKEY* out
Access: DWORD; // DWORD
OpenExisting: BOOL // BOOL
): DWORD; stdcall;
external 'POWRPROF.dll' name 'PowerOpenSystemPowerKey';result := DllCall("POWRPROF\PowerOpenSystemPowerKey"
, "Ptr", phSystemPowerKey ; HKEY* out
, "UInt", Access ; DWORD
, "Int", OpenExisting ; BOOL
, "UInt") ; return: DWORD●PowerOpenSystemPowerKey(phSystemPowerKey, Access, OpenExisting) = DLL("POWRPROF.dll", "dword PowerOpenSystemPowerKey(void*, dword, bool)")
# 呼び出し: PowerOpenSystemPowerKey(phSystemPowerKey, Access, OpenExisting)
# phSystemPowerKey : HKEY* out -> "void*"
# Access : DWORD -> "dword"
# OpenExisting : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。