ホーム › Networking.Clustering › CreateClusterNotifyPortV2
CreateClusterNotifyPortV2
関数V2形式のクラスター通知ポートを作成する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
HCHANGE CreateClusterNotifyPortV2(
HCHANGE hChange,
HCLUSTER hCluster,
NOTIFY_FILTER_AND_TYPE* Filters,
DWORD dwFilterCount,
UINT_PTR dwNotifyKey
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hChange | HCHANGE | in | 既存の通知ポートハンドル。新規作成時はINVALID_HANDLE_VALUEを指定する。 |
| hCluster | HCLUSTER | in | 通知を受け取る対象クラスタへのハンドル。 |
| Filters | NOTIFY_FILTER_AND_TYPE* | in | 受信するイベント種別とフィルタを示す構造体配列へのポインタ。 |
| dwFilterCount | DWORD | in | Filters配列に含まれるフィルタの個数。 |
| dwNotifyKey | UINT_PTR | in | このフィルタ群に紐付けるユーザー定義キー。通知取得時に返される。 |
戻り値の型: 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 方式にも切替可。#uselib "CLUSAPI.dll" #cfunc global CreateClusterNotifyPortV2 "CreateClusterNotifyPortV2" sptr, sptr, sptr, int, sptr ; res = CreateClusterNotifyPortV2(hChange, hCluster, varptr(Filters), dwFilterCount, dwNotifyKey) ; hChange : HCHANGE -> "sptr" ; hCluster : HCLUSTER -> "sptr" ; Filters : NOTIFY_FILTER_AND_TYPE* -> "sptr" ; dwFilterCount : DWORD -> "int" ; dwNotifyKey : UINT_PTR -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, intptr ; res = CreateClusterNotifyPortV2(hChange, hCluster, varptr(Filters), dwFilterCount, dwNotifyKey) ; hChange : HCHANGE -> "intptr" ; hCluster : HCLUSTER -> "intptr" ; Filters : NOTIFY_FILTER_AND_TYPE* -> "intptr" ; dwFilterCount : DWORD -> "int" ; dwNotifyKey : UINT_PTR -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HCHANGEfunction 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)。const std = @import("std");
extern "clusapi" fn CreateClusterNotifyPortV2(
hChange: isize, // HCHANGE
hCluster: isize, // HCLUSTER
Filters: [*c]NOTIFY_FILTER_AND_TYPE, // NOTIFY_FILTER_AND_TYPE*
dwFilterCount: u32, // DWORD
dwNotifyKey: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) isize;proc CreateClusterNotifyPortV2(
hChange: int, # HCHANGE
hCluster: int, # HCLUSTER
Filters: ptr NOTIFY_FILTER_AND_TYPE, # NOTIFY_FILTER_AND_TYPE*
dwFilterCount: uint32, # DWORD
dwNotifyKey: uint # UINT_PTR
): int {.importc: "CreateClusterNotifyPortV2", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
ptrdiff_t CreateClusterNotifyPortV2(
ptrdiff_t hChange, // HCHANGE
ptrdiff_t hCluster, // HCLUSTER
NOTIFY_FILTER_AND_TYPE* Filters, // NOTIFY_FILTER_AND_TYPE*
uint dwFilterCount, // DWORD
size_t dwNotifyKey // UINT_PTR
);ccall((:CreateClusterNotifyPortV2, "CLUSAPI.dll"), stdcall, Int,
(Int, Int, Ptr{NOTIFY_FILTER_AND_TYPE}, UInt32, Csize_t),
hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
# hChange : HCHANGE -> Int
# hCluster : HCLUSTER -> Int
# Filters : NOTIFY_FILTER_AND_TYPE* -> Ptr{NOTIFY_FILTER_AND_TYPE}
# dwFilterCount : DWORD -> UInt32
# dwNotifyKey : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
intptr_t CreateClusterNotifyPortV2(
intptr_t hChange,
intptr_t hCluster,
void* Filters,
uint32_t dwFilterCount,
uintptr_t dwNotifyKey);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
-- hChange : HCHANGE
-- hCluster : HCLUSTER
-- Filters : NOTIFY_FILTER_AND_TYPE*
-- dwFilterCount : DWORD
-- dwNotifyKey : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const CreateClusterNotifyPortV2 = lib.func('__stdcall', 'CreateClusterNotifyPortV2', 'intptr_t', ['intptr_t', 'intptr_t', 'void *', 'uint32_t', 'uintptr_t']);
// CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
// hChange : HCHANGE -> 'intptr_t'
// hCluster : HCLUSTER -> 'intptr_t'
// Filters : NOTIFY_FILTER_AND_TYPE* -> 'void *'
// dwFilterCount : DWORD -> 'uint32_t'
// dwNotifyKey : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
CreateClusterNotifyPortV2: { parameters: ["isize", "isize", "pointer", "u32", "usize"], result: "isize" },
});
// lib.symbols.CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey)
// hChange : HCHANGE -> "isize"
// hCluster : HCLUSTER -> "isize"
// Filters : NOTIFY_FILTER_AND_TYPE* -> "pointer"
// dwFilterCount : DWORD -> "u32"
// dwNotifyKey : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t CreateClusterNotifyPortV2(
intptr_t hChange,
intptr_t hCluster,
void* Filters,
uint32_t dwFilterCount,
size_t dwNotifyKey);
C, "CLUSAPI.dll");
// $ffi->CreateClusterNotifyPortV2(hChange, hCluster, Filters, dwFilterCount, dwNotifyKey);
// hChange : HCHANGE
// hCluster : HCLUSTER
// Filters : NOTIFY_FILTER_AND_TYPE*
// dwFilterCount : DWORD
// 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);
long CreateClusterNotifyPortV2(
long hChange, // HCHANGE
long hCluster, // HCLUSTER
Pointer Filters, // NOTIFY_FILTER_AND_TYPE*
int dwFilterCount, // DWORD
long dwNotifyKey // UINT_PTR
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun CreateClusterNotifyPortV2 = CreateClusterNotifyPortV2(
hChange : LibC::SSizeT, # HCHANGE
hCluster : LibC::SSizeT, # HCLUSTER
Filters : NOTIFY_FILTER_AND_TYPE*, # NOTIFY_FILTER_AND_TYPE*
dwFilterCount : UInt32, # DWORD
dwNotifyKey : LibC::SizeT # UINT_PTR
) : LibC::SSizeT
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateClusterNotifyPortV2Native = IntPtr Function(IntPtr, IntPtr, Pointer<Void>, Uint32, UintPtr);
typedef CreateClusterNotifyPortV2Dart = int Function(int, int, Pointer<Void>, int, int);
final CreateClusterNotifyPortV2 = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<CreateClusterNotifyPortV2Native, CreateClusterNotifyPortV2Dart>('CreateClusterNotifyPortV2');
// hChange : HCHANGE -> IntPtr
// hCluster : HCLUSTER -> IntPtr
// Filters : NOTIFY_FILTER_AND_TYPE* -> Pointer<Void>
// dwFilterCount : DWORD -> Uint32
// dwNotifyKey : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateClusterNotifyPortV2"
c_CreateClusterNotifyPortV2 :: CIntPtr -> CIntPtr -> Ptr () -> Word32 -> CUIntPtr -> IO CIntPtr
-- hChange : HCHANGE -> CIntPtr
-- hCluster : HCLUSTER -> CIntPtr
-- Filters : NOTIFY_FILTER_AND_TYPE* -> Ptr ()
-- dwFilterCount : DWORD -> Word32
-- dwNotifyKey : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createclusternotifyportv2 =
foreign "CreateClusterNotifyPortV2"
(intptr_t @-> intptr_t @-> (ptr void) @-> uint32_t @-> size_t @-> returning intptr_t)
(* hChange : HCHANGE -> intptr_t *)
(* hCluster : HCLUSTER -> intptr_t *)
(* Filters : NOTIFY_FILTER_AND_TYPE* -> (ptr void) *)
(* dwFilterCount : DWORD -> uint32_t *)
(* 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 ("CreateClusterNotifyPortV2" create-cluster-notify-port-v2 :convention :stdcall) :int64
(h-change :int64) ; HCHANGE
(h-cluster :int64) ; HCLUSTER
(filters :pointer) ; NOTIFY_FILTER_AND_TYPE*
(dw-filter-count :uint32) ; DWORD
(dw-notify-key :uint64)) ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateClusterNotifyPortV2 = Win32::API::More->new('CLUSAPI',
'LPARAM CreateClusterNotifyPortV2(LPARAM hChange, LPARAM hCluster, LPVOID Filters, DWORD dwFilterCount, WPARAM dwNotifyKey)');
# my $ret = $CreateClusterNotifyPortV2->Call($hChange, $hCluster, $Filters, $dwFilterCount, $dwNotifyKey);
# hChange : HCHANGE -> LPARAM
# hCluster : HCLUSTER -> LPARAM
# Filters : NOTIFY_FILTER_AND_TYPE* -> LPVOID
# dwFilterCount : DWORD -> DWORD
# dwNotifyKey : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。