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

RegisterClusterNotify

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

シグネチャ

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

DWORD RegisterClusterNotify(
    HCHANGE hChange,
    DWORD dwFilterType,
    HANDLE hObject,
    UINT_PTR dwNotifyKey
);

パラメーター

名前方向説明
hChangeHCHANGEinCreateClusterNotifyPortで作成した通知ポートハンドル。
dwFilterTypeDWORDin登録するイベント種別を示すCLUSTER_CHANGE_*ビットフラグ。
hObjectHANDLEin通知対象のクラスタオブジェクトハンドル。
dwNotifyKeyUINT_PTRinこの登録に紐付けるユーザー定義キー。通知取得時に返される。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RegisterClusterNotify(
    HCHANGE hChange,
    DWORD dwFilterType,
    HANDLE hObject,
    UINT_PTR dwNotifyKey
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint RegisterClusterNotify(
    IntPtr hChange,   // HCHANGE
    uint dwFilterType,   // DWORD
    IntPtr hObject,   // HANDLE
    UIntPtr dwNotifyKey   // UINT_PTR
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function RegisterClusterNotify(
    hChange As IntPtr,   ' HCHANGE
    dwFilterType As UInteger,   ' DWORD
    hObject As IntPtr,   ' HANDLE
    dwNotifyKey As UIntPtr   ' UINT_PTR
) As UInteger
End Function
' hChange : HCHANGE
' dwFilterType : DWORD
' hObject : HANDLE
' dwNotifyKey : UINT_PTR
Declare PtrSafe Function RegisterClusterNotify Lib "clusapi" ( _
    ByVal hChange As LongPtr, _
    ByVal dwFilterType As Long, _
    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

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

lib = Fiddle.dlopen('CLUSAPI.dll')
RegisterClusterNotify = Fiddle::Function.new(
  lib['RegisterClusterNotify'],
  [
    Fiddle::TYPE_INTPTR_T,  # hChange : HCHANGE
    -Fiddle::TYPE_INT,  # dwFilterType : DWORD
    Fiddle::TYPE_VOIDP,  # hObject : HANDLE
    Fiddle::TYPE_UINTPTR_T,  # dwNotifyKey : UINT_PTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn RegisterClusterNotify(
        hChange: isize,  // HCHANGE
        dwFilterType: u32,  // DWORD
        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 RegisterClusterNotify(IntPtr hChange, uint dwFilterType, IntPtr hObject, UIntPtr dwNotifyKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_RegisterClusterNotify' -Namespace Win32 -PassThru
# $api::RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
#uselib "CLUSAPI.dll"
#func global RegisterClusterNotify "RegisterClusterNotify" sptr, sptr, sptr, sptr
; RegisterClusterNotify hChange, dwFilterType, hObject, dwNotifyKey   ; 戻り値は stat
; hChange : HCHANGE -> "sptr"
; dwFilterType : DWORD -> "sptr"
; hObject : HANDLE -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterNotify "RegisterClusterNotify" sptr, int, sptr, sptr
; res = RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
; hChange : HCHANGE -> "sptr"
; dwFilterType : DWORD -> "int"
; hObject : HANDLE -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; DWORD RegisterClusterNotify(HCHANGE hChange, DWORD dwFilterType, HANDLE hObject, UINT_PTR dwNotifyKey)
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterNotify "RegisterClusterNotify" intptr, int, intptr, intptr
; res = RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
; hChange : HCHANGE -> "intptr"
; dwFilterType : DWORD -> "int"
; hObject : HANDLE -> "intptr"
; dwNotifyKey : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procRegisterClusterNotify = clusapi.NewProc("RegisterClusterNotify")
)

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

extern "clusapi" fn RegisterClusterNotify(
    hChange: isize, // HCHANGE
    dwFilterType: u32, // DWORD
    hObject: ?*anyopaque, // HANDLE
    dwNotifyKey: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) u32;
proc RegisterClusterNotify(
    hChange: int,  # HCHANGE
    dwFilterType: uint32,  # DWORD
    hObject: pointer,  # HANDLE
    dwNotifyKey: uint  # UINT_PTR
): uint32 {.importc: "RegisterClusterNotify", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
uint RegisterClusterNotify(
    ptrdiff_t hChange,   // HCHANGE
    uint dwFilterType,   // DWORD
    void* hObject,   // HANDLE
    size_t dwNotifyKey   // UINT_PTR
);
ccall((:RegisterClusterNotify, "CLUSAPI.dll"), stdcall, UInt32,
      (Int, UInt32, Ptr{Cvoid}, Csize_t),
      hChange, dwFilterType, hObject, dwNotifyKey)
# hChange : HCHANGE -> Int
# dwFilterType : DWORD -> UInt32
# hObject : HANDLE -> Ptr{Cvoid}
# dwNotifyKey : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t RegisterClusterNotify(
    intptr_t hChange,
    uint32_t dwFilterType,
    void* hObject,
    uintptr_t dwNotifyKey);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
-- hChange : HCHANGE
-- dwFilterType : DWORD
-- hObject : HANDLE
-- dwNotifyKey : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const RegisterClusterNotify = lib.func('__stdcall', 'RegisterClusterNotify', 'uint32_t', ['intptr_t', 'uint32_t', 'void *', 'uintptr_t']);
// RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
// hChange : HCHANGE -> 'intptr_t'
// dwFilterType : DWORD -> 'uint32_t'
// hObject : HANDLE -> 'void *'
// dwNotifyKey : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  RegisterClusterNotify: { parameters: ["isize", "u32", "pointer", "usize"], result: "u32" },
});
// lib.symbols.RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey)
// hChange : HCHANGE -> "isize"
// dwFilterType : DWORD -> "u32"
// hObject : HANDLE -> "pointer"
// dwNotifyKey : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t RegisterClusterNotify(
    intptr_t hChange,
    uint32_t dwFilterType,
    void* hObject,
    size_t dwNotifyKey);
C, "CLUSAPI.dll");
// $ffi->RegisterClusterNotify(hChange, dwFilterType, hObject, dwNotifyKey);
// hChange : HCHANGE
// dwFilterType : DWORD
// hObject : HANDLE
// dwNotifyKey : UINT_PTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Clusapi extends StdCallLibrary {
    Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
    int RegisterClusterNotify(
        long hChange,   // HCHANGE
        int dwFilterType,   // DWORD
        Pointer hObject,   // HANDLE
        long dwNotifyKey   // UINT_PTR
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun RegisterClusterNotify = RegisterClusterNotify(
    hChange : LibC::SSizeT,   # HCHANGE
    dwFilterType : UInt32,   # DWORD
    hObject : Void*,   # HANDLE
    dwNotifyKey : LibC::SizeT   # UINT_PTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RegisterClusterNotifyNative = Uint32 Function(IntPtr, Uint32, Pointer<Void>, UintPtr);
typedef RegisterClusterNotifyDart = int Function(int, int, Pointer<Void>, int);
final RegisterClusterNotify = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<RegisterClusterNotifyNative, RegisterClusterNotifyDart>('RegisterClusterNotify');
// hChange : HCHANGE -> IntPtr
// dwFilterType : DWORD -> Uint32
// hObject : HANDLE -> Pointer<Void>
// dwNotifyKey : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RegisterClusterNotify(
  hChange: NativeInt;   // HCHANGE
  dwFilterType: DWORD;   // DWORD
  hObject: THandle;   // HANDLE
  dwNotifyKey: NativeUInt   // UINT_PTR
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'RegisterClusterNotify';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RegisterClusterNotify"
  c_RegisterClusterNotify :: CIntPtr -> Word32 -> Ptr () -> CUIntPtr -> IO Word32
-- hChange : HCHANGE -> CIntPtr
-- dwFilterType : DWORD -> Word32
-- hObject : HANDLE -> Ptr ()
-- dwNotifyKey : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let registerclusternotify =
  foreign "RegisterClusterNotify"
    (intptr_t @-> uint32_t @-> (ptr void) @-> size_t @-> returning uint32_t)
(* hChange : HCHANGE -> intptr_t *)
(* dwFilterType : DWORD -> uint32_t *)
(* hObject : HANDLE -> (ptr void) *)
(* dwNotifyKey : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("RegisterClusterNotify" register-cluster-notify :convention :stdcall) :uint32
  (h-change :int64)   ; HCHANGE
  (dw-filter-type :uint32)   ; DWORD
  (h-object :pointer)   ; HANDLE
  (dw-notify-key :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RegisterClusterNotify = Win32::API::More->new('CLUSAPI',
    'DWORD RegisterClusterNotify(LPARAM hChange, DWORD dwFilterType, HANDLE hObject, WPARAM dwNotifyKey)');
# my $ret = $RegisterClusterNotify->Call($hChange, $dwFilterType, $hObject, $dwNotifyKey);
# hChange : HCHANGE -> LPARAM
# dwFilterType : DWORD -> DWORD
# hObject : HANDLE -> HANDLE
# dwNotifyKey : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。