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

DevicePowerOpen

関数
デバイス電源データベースを初期化して開く。
DLLPOWRPROF.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOLEAN DevicePowerOpen(
    DWORD DebugMask   // optional
);

パラメーター

名前方向
DebugMaskDWORDinoptional

戻り値の型: BOOLEAN

各言語での呼び出し定義

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

BOOLEAN DevicePowerOpen(
    DWORD DebugMask   // optional
);
[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern byte DevicePowerOpen(
    uint DebugMask   // DWORD optional
);
<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function DevicePowerOpen(
    DebugMask As UInteger   ' DWORD optional
) As Byte
End Function
' DebugMask : DWORD optional
Declare PtrSafe Function DevicePowerOpen Lib "powrprof" ( _
    ByVal DebugMask As Long) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DevicePowerOpen = ctypes.windll.powrprof.DevicePowerOpen
DevicePowerOpen.restype = ctypes.c_byte
DevicePowerOpen.argtypes = [
    wintypes.DWORD,  # DebugMask : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
	procDevicePowerOpen = powrprof.NewProc("DevicePowerOpen")
)

// DebugMask (DWORD optional)
r1, _, err := procDevicePowerOpen.Call(
	uintptr(DebugMask),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOLEAN
function DevicePowerOpen(
  DebugMask: DWORD   // DWORD optional
): ByteBool; stdcall;
  external 'POWRPROF.dll' name 'DevicePowerOpen';
result := DllCall("POWRPROF\DevicePowerOpen"
    , "UInt", DebugMask   ; DWORD optional
    , "Char")   ; return: BOOLEAN
●DevicePowerOpen(DebugMask) = DLL("POWRPROF.dll", "byte DevicePowerOpen(dword)")
# 呼び出し: DevicePowerOpen(DebugMask)
# DebugMask : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。