Win32 API 日本語リファレンス
ホームNetworking.Clustering › RegisterClusterNotifyV2

RegisterClusterNotifyV2

関数
V2通知ポートにイベントフィルターを登録する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2016

シグネチャ

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

DWORD RegisterClusterNotifyV2(
    HCHANGE hChange,
    NOTIFY_FILTER_AND_TYPE Filter,
    HANDLE hObject,
    UINT_PTR dwNotifyKey
);

パラメーター

名前方向
hChangeHCHANGEin
FilterNOTIFY_FILTER_AND_TYPEin
hObjectHANDLEin
dwNotifyKeyUINT_PTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RegisterClusterNotifyV2(
    HCHANGE hChange,
    NOTIFY_FILTER_AND_TYPE Filter,
    HANDLE hObject,
    UINT_PTR dwNotifyKey
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint RegisterClusterNotifyV2(
    IntPtr hChange,   // HCHANGE
    NOTIFY_FILTER_AND_TYPE Filter,   // NOTIFY_FILTER_AND_TYPE
    IntPtr hObject,   // HANDLE
    UIntPtr dwNotifyKey   // UINT_PTR
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function RegisterClusterNotifyV2(
    hChange As IntPtr,   ' HCHANGE
    Filter As NOTIFY_FILTER_AND_TYPE,   ' NOTIFY_FILTER_AND_TYPE
    hObject As IntPtr,   ' HANDLE
    dwNotifyKey As UIntPtr   ' UINT_PTR
) As UInteger
End Function
' hChange : HCHANGE
' Filter : NOTIFY_FILTER_AND_TYPE
' hObject : HANDLE
' dwNotifyKey : UINT_PTR
Declare PtrSafe Function RegisterClusterNotifyV2 Lib "clusapi" ( _
    ByVal hChange As LongPtr, _
    ByVal Filter As LongPtr, _
    ByVal hObject As LongPtr, _
    ByVal dwNotifyKey As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegisterClusterNotifyV2 = ctypes.windll.clusapi.RegisterClusterNotifyV2
RegisterClusterNotifyV2.restype = wintypes.DWORD
RegisterClusterNotifyV2.argtypes = [
    ctypes.c_ssize_t,  # hChange : HCHANGE
    NOTIFY_FILTER_AND_TYPE,  # Filter : NOTIFY_FILTER_AND_TYPE
    wintypes.HANDLE,  # hObject : HANDLE
    ctypes.c_size_t,  # dwNotifyKey : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
RegisterClusterNotifyV2 = Fiddle::Function.new(
  lib['RegisterClusterNotifyV2'],
  [
    Fiddle::TYPE_INTPTR_T,  # hChange : HCHANGE
    Fiddle::TYPE_VOIDP,  # Filter : NOTIFY_FILTER_AND_TYPE
    Fiddle::TYPE_VOIDP,  # hObject : HANDLE
    Fiddle::TYPE_UINTPTR_T,  # dwNotifyKey : UINT_PTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn RegisterClusterNotifyV2(
        hChange: isize,  // HCHANGE
        Filter: NOTIFY_FILTER_AND_TYPE,  // NOTIFY_FILTER_AND_TYPE
        hObject: *mut core::ffi::c_void,  // HANDLE
        dwNotifyKey: usize  // UINT_PTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint RegisterClusterNotifyV2(IntPtr hChange, NOTIFY_FILTER_AND_TYPE Filter, IntPtr hObject, UIntPtr dwNotifyKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_RegisterClusterNotifyV2' -Namespace Win32 -PassThru
# $api::RegisterClusterNotifyV2(hChange, Filter, hObject, dwNotifyKey)
#uselib "CLUSAPI.dll"
#func global RegisterClusterNotifyV2 "RegisterClusterNotifyV2" sptr, sptr, sptr, sptr
; RegisterClusterNotifyV2 hChange, Filter, hObject, dwNotifyKey   ; 戻り値は stat
; hChange : HCHANGE -> "sptr"
; Filter : NOTIFY_FILTER_AND_TYPE -> "sptr"
; hObject : HANDLE -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterNotifyV2 "RegisterClusterNotifyV2" sptr, int, sptr, sptr
; res = RegisterClusterNotifyV2(hChange, Filter, hObject, dwNotifyKey)
; hChange : HCHANGE -> "sptr"
; Filter : NOTIFY_FILTER_AND_TYPE -> "int"
; hObject : HANDLE -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; DWORD RegisterClusterNotifyV2(HCHANGE hChange, NOTIFY_FILTER_AND_TYPE Filter, HANDLE hObject, UINT_PTR dwNotifyKey)
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterNotifyV2 "RegisterClusterNotifyV2" intptr, int, intptr, intptr
; res = RegisterClusterNotifyV2(hChange, Filter, hObject, dwNotifyKey)
; hChange : HCHANGE -> "intptr"
; Filter : NOTIFY_FILTER_AND_TYPE -> "int"
; hObject : HANDLE -> "intptr"
; dwNotifyKey : UINT_PTR -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procRegisterClusterNotifyV2 = clusapi.NewProc("RegisterClusterNotifyV2")
)

// hChange (HCHANGE), Filter (NOTIFY_FILTER_AND_TYPE), hObject (HANDLE), dwNotifyKey (UINT_PTR)
r1, _, err := procRegisterClusterNotifyV2.Call(
	uintptr(hChange),
	uintptr(Filter),
	uintptr(hObject),
	uintptr(dwNotifyKey),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RegisterClusterNotifyV2(
  hChange: NativeInt;   // HCHANGE
  Filter: NOTIFY_FILTER_AND_TYPE;   // NOTIFY_FILTER_AND_TYPE
  hObject: THandle;   // HANDLE
  dwNotifyKey: NativeUInt   // UINT_PTR
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'RegisterClusterNotifyV2';
result := DllCall("CLUSAPI\RegisterClusterNotifyV2"
    , "Ptr", hChange   ; HCHANGE
    , "Ptr", Filter   ; NOTIFY_FILTER_AND_TYPE
    , "Ptr", hObject   ; HANDLE
    , "UPtr", dwNotifyKey   ; UINT_PTR
    , "UInt")   ; return: DWORD
●RegisterClusterNotifyV2(hChange, Filter, hObject, dwNotifyKey) = DLL("CLUSAPI.dll", "dword RegisterClusterNotifyV2(int, void*, void*, int)")
# 呼び出し: RegisterClusterNotifyV2(hChange, Filter, hObject, dwNotifyKey)
# hChange : HCHANGE -> "int"
# Filter : NOTIFY_FILTER_AND_TYPE -> "void*"
# hObject : HANDLE -> "void*"
# dwNotifyKey : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。