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

PowerRegisterSuspendResumeNotification

関数
サスペンドおよびレジューム通知の受信を登録する。
DLLPOWRPROF.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

WIN32_ERROR PowerRegisterSuspendResumeNotification(
    REGISTER_NOTIFICATION_FLAGS Flags,
    HANDLE Recipient,
    void** RegistrationHandle
);

パラメーター

名前方向
FlagsREGISTER_NOTIFICATION_FLAGSin
RecipientHANDLEin
RegistrationHandlevoid**out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR PowerRegisterSuspendResumeNotification(
    REGISTER_NOTIFICATION_FLAGS Flags,
    HANDLE Recipient,
    void** RegistrationHandle
);
[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern uint PowerRegisterSuspendResumeNotification(
    uint Flags,   // REGISTER_NOTIFICATION_FLAGS
    IntPtr Recipient,   // HANDLE
    IntPtr RegistrationHandle   // void** out
);
<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function PowerRegisterSuspendResumeNotification(
    Flags As UInteger,   ' REGISTER_NOTIFICATION_FLAGS
    Recipient As IntPtr,   ' HANDLE
    RegistrationHandle As IntPtr   ' void** out
) As UInteger
End Function
' Flags : REGISTER_NOTIFICATION_FLAGS
' Recipient : HANDLE
' RegistrationHandle : void** out
Declare PtrSafe Function PowerRegisterSuspendResumeNotification Lib "powrprof" ( _
    ByVal Flags As Long, _
    ByVal Recipient As LongPtr, _
    ByVal RegistrationHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PowerRegisterSuspendResumeNotification = ctypes.windll.powrprof.PowerRegisterSuspendResumeNotification
PowerRegisterSuspendResumeNotification.restype = wintypes.DWORD
PowerRegisterSuspendResumeNotification.argtypes = [
    wintypes.DWORD,  # Flags : REGISTER_NOTIFICATION_FLAGS
    wintypes.HANDLE,  # Recipient : HANDLE
    ctypes.c_void_p,  # RegistrationHandle : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
	procPowerRegisterSuspendResumeNotification = powrprof.NewProc("PowerRegisterSuspendResumeNotification")
)

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