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

CreateClusterNotifyPortV2

関数
V2形式のクラスター通知ポートを作成する。
DLLCLUSAPI.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2012

シグネチャ

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

HCHANGE CreateClusterNotifyPortV2(
    HCHANGE hChange,
    HCLUSTER hCluster,
    NOTIFY_FILTER_AND_TYPE* Filters,
    DWORD dwFilterCount,
    UINT_PTR dwNotifyKey
);

パラメーター

名前方向
hChangeHCHANGEin
hClusterHCLUSTERin
FiltersNOTIFY_FILTER_AND_TYPE*in
dwFilterCountDWORDin
dwNotifyKeyUINT_PTRin

戻り値の型: HCHANGE

各言語での呼び出し定義

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

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

CreateClusterNotifyPortV2 = ctypes.windll.clusapi.CreateClusterNotifyPortV2
CreateClusterNotifyPortV2.restype = ctypes.c_ssize_t
CreateClusterNotifyPortV2.argtypes = [
    ctypes.c_ssize_t,  # hChange : HCHANGE
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    ctypes.c_void_p,  # Filters : NOTIFY_FILTER_AND_TYPE*
    wintypes.DWORD,  # dwFilterCount : DWORD
    ctypes.c_size_t,  # dwNotifyKey : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
CreateClusterNotifyPortV2 = Fiddle::Function.new(
  lib['CreateClusterNotifyPortV2'],
  [
    Fiddle::TYPE_INTPTR_T,  # hChange : HCHANGE
    Fiddle::TYPE_INTPTR_T,  # hCluster : HCLUSTER
    Fiddle::TYPE_VOIDP,  # Filters : NOTIFY_FILTER_AND_TYPE*
    -Fiddle::TYPE_INT,  # dwFilterCount : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwNotifyKey : UINT_PTR
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "clusapi")]
extern "system" {
    fn CreateClusterNotifyPortV2(
        hChange: isize,  // HCHANGE
        hCluster: isize,  // HCLUSTER
        Filters: *mut NOTIFY_FILTER_AND_TYPE,  // NOTIFY_FILTER_AND_TYPE*
        dwFilterCount: u32,  // DWORD
        dwNotifyKey: usize  // UINT_PTR
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll", SetLastError = true)]
public static extern IntPtr CreateClusterNotifyPortV2(IntPtr hChange, IntPtr hCluster, IntPtr Filters, uint dwFilterCount, UIntPtr dwNotifyKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_CreateClusterNotifyPortV2' -Namespace Win32 -PassThru
# $api::CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
#uselib "CLUSAPI.dll"
#func global CreateClusterNotifyPortV2 "CreateClusterNotifyPortV2" sptr, sptr, sptr, sptr, sptr
; CreateClusterNotifyPortV2 hChange, hCluster, varptr(Filters), dwFilterCount, dwNotifyKey   ; 戻り値は stat
; hChange : HCHANGE -> "sptr"
; hCluster : HCLUSTER -> "sptr"
; Filters : NOTIFY_FILTER_AND_TYPE* -> "sptr"
; dwFilterCount : DWORD -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CLUSAPI.dll"
#cfunc global CreateClusterNotifyPortV2 "CreateClusterNotifyPortV2" sptr, sptr, var, int, sptr
; res = CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
; hChange : HCHANGE -> "sptr"
; hCluster : HCLUSTER -> "sptr"
; Filters : NOTIFY_FILTER_AND_TYPE* -> "var"
; dwFilterCount : DWORD -> "int"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HCHANGE CreateClusterNotifyPortV2(HCHANGE hChange, HCLUSTER hCluster, NOTIFY_FILTER_AND_TYPE* Filters, DWORD dwFilterCount, UINT_PTR dwNotifyKey)
#uselib "CLUSAPI.dll"
#cfunc global CreateClusterNotifyPortV2 "CreateClusterNotifyPortV2" intptr, intptr, var, int, intptr
; res = CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
; hChange : HCHANGE -> "intptr"
; hCluster : HCLUSTER -> "intptr"
; Filters : NOTIFY_FILTER_AND_TYPE* -> "var"
; dwFilterCount : DWORD -> "int"
; dwNotifyKey : UINT_PTR -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procCreateClusterNotifyPortV2 = clusapi.NewProc("CreateClusterNotifyPortV2")
)

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