ホーム › Networking.Clustering › GetClusterNotify
GetClusterNotify
関数通知ポートから次のクラスター通知イベントを取得する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
DWORD GetClusterNotify(
HCHANGE hChange,
UINT_PTR* lpdwNotifyKey,
DWORD* lpdwFilterType,
LPWSTR lpszName,
DWORD* lpcchName,
DWORD dwMilliseconds
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hChange | HCHANGE | in |
| lpdwNotifyKey | UINT_PTR* | out |
| lpdwFilterType | DWORD* | out |
| lpszName | LPWSTR | out |
| lpcchName | DWORD* | inout |
| dwMilliseconds | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
DWORD GetClusterNotify(
HCHANGE hChange,
UINT_PTR* lpdwNotifyKey,
DWORD* lpdwFilterType,
LPWSTR lpszName,
DWORD* lpcchName,
DWORD dwMilliseconds
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint GetClusterNotify(
IntPtr hChange, // HCHANGE
out UIntPtr lpdwNotifyKey, // UINT_PTR* out
out uint lpdwFilterType, // DWORD* out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName, // LPWSTR out
ref uint lpcchName, // DWORD* in/out
uint dwMilliseconds // DWORD
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function GetClusterNotify(
hChange As IntPtr, ' HCHANGE
<Out> ByRef lpdwNotifyKey As UIntPtr, ' UINT_PTR* out
<Out> ByRef lpdwFilterType As UInteger, ' DWORD* out
<MarshalAs(UnmanagedType.LPWStr)> lpszName As System.Text.StringBuilder, ' LPWSTR out
ByRef lpcchName As UInteger, ' DWORD* in/out
dwMilliseconds As UInteger ' DWORD
) As UInteger
End Function' hChange : HCHANGE
' lpdwNotifyKey : UINT_PTR* out
' lpdwFilterType : DWORD* out
' lpszName : LPWSTR out
' lpcchName : DWORD* in/out
' dwMilliseconds : DWORD
Declare PtrSafe Function GetClusterNotify Lib "clusapi" ( _
ByVal hChange As LongPtr, _
ByRef lpdwNotifyKey As LongPtr, _
ByRef lpdwFilterType As Long, _
ByVal lpszName As LongPtr, _
ByRef lpcchName As Long, _
ByVal dwMilliseconds As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetClusterNotify = ctypes.windll.clusapi.GetClusterNotify
GetClusterNotify.restype = wintypes.DWORD
GetClusterNotify.argtypes = [
ctypes.c_ssize_t, # hChange : HCHANGE
ctypes.POINTER(ctypes.c_size_t), # lpdwNotifyKey : UINT_PTR* out
ctypes.POINTER(wintypes.DWORD), # lpdwFilterType : DWORD* out
wintypes.LPWSTR, # lpszName : LPWSTR out
ctypes.POINTER(wintypes.DWORD), # lpcchName : DWORD* in/out
wintypes.DWORD, # dwMilliseconds : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
GetClusterNotify = Fiddle::Function.new(
lib['GetClusterNotify'],
[
Fiddle::TYPE_INTPTR_T, # hChange : HCHANGE
Fiddle::TYPE_VOIDP, # lpdwNotifyKey : UINT_PTR* out
Fiddle::TYPE_VOIDP, # lpdwFilterType : DWORD* out
Fiddle::TYPE_VOIDP, # lpszName : LPWSTR out
Fiddle::TYPE_VOIDP, # lpcchName : DWORD* in/out
-Fiddle::TYPE_INT, # dwMilliseconds : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn GetClusterNotify(
hChange: isize, // HCHANGE
lpdwNotifyKey: *mut usize, // UINT_PTR* out
lpdwFilterType: *mut u32, // DWORD* out
lpszName: *mut u16, // LPWSTR out
lpcchName: *mut u32, // DWORD* in/out
dwMilliseconds: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint GetClusterNotify(IntPtr hChange, out UIntPtr lpdwNotifyKey, out uint lpdwFilterType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName, ref uint lpcchName, uint dwMilliseconds);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_GetClusterNotify' -Namespace Win32 -PassThru
# $api::GetClusterNotify(hChange, lpdwNotifyKey, lpdwFilterType, lpszName, lpcchName, dwMilliseconds)#uselib "CLUSAPI.dll"
#func global GetClusterNotify "GetClusterNotify" sptr, sptr, sptr, sptr, sptr, sptr
; GetClusterNotify hChange, varptr(lpdwNotifyKey), varptr(lpdwFilterType), varptr(lpszName), varptr(lpcchName), dwMilliseconds ; 戻り値は stat
; hChange : HCHANGE -> "sptr"
; lpdwNotifyKey : UINT_PTR* out -> "sptr"
; lpdwFilterType : DWORD* out -> "sptr"
; lpszName : LPWSTR out -> "sptr"
; lpcchName : DWORD* in/out -> "sptr"
; dwMilliseconds : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CLUSAPI.dll" #cfunc global GetClusterNotify "GetClusterNotify" sptr, var, var, var, var, int ; res = GetClusterNotify(hChange, lpdwNotifyKey, lpdwFilterType, lpszName, lpcchName, dwMilliseconds) ; hChange : HCHANGE -> "sptr" ; lpdwNotifyKey : UINT_PTR* out -> "var" ; lpdwFilterType : DWORD* out -> "var" ; lpszName : LPWSTR out -> "var" ; lpcchName : DWORD* in/out -> "var" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CLUSAPI.dll" #cfunc global GetClusterNotify "GetClusterNotify" sptr, sptr, sptr, sptr, sptr, int ; res = GetClusterNotify(hChange, varptr(lpdwNotifyKey), varptr(lpdwFilterType), varptr(lpszName), varptr(lpcchName), dwMilliseconds) ; hChange : HCHANGE -> "sptr" ; lpdwNotifyKey : UINT_PTR* out -> "sptr" ; lpdwFilterType : DWORD* out -> "sptr" ; lpszName : LPWSTR out -> "sptr" ; lpcchName : DWORD* in/out -> "sptr" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetClusterNotify(HCHANGE hChange, UINT_PTR* lpdwNotifyKey, DWORD* lpdwFilterType, LPWSTR lpszName, DWORD* lpcchName, DWORD dwMilliseconds) #uselib "CLUSAPI.dll" #cfunc global GetClusterNotify "GetClusterNotify" intptr, var, var, var, var, int ; res = GetClusterNotify(hChange, lpdwNotifyKey, lpdwFilterType, lpszName, lpcchName, dwMilliseconds) ; hChange : HCHANGE -> "intptr" ; lpdwNotifyKey : UINT_PTR* out -> "var" ; lpdwFilterType : DWORD* out -> "var" ; lpszName : LPWSTR out -> "var" ; lpcchName : DWORD* in/out -> "var" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetClusterNotify(HCHANGE hChange, UINT_PTR* lpdwNotifyKey, DWORD* lpdwFilterType, LPWSTR lpszName, DWORD* lpcchName, DWORD dwMilliseconds) #uselib "CLUSAPI.dll" #cfunc global GetClusterNotify "GetClusterNotify" intptr, intptr, intptr, intptr, intptr, int ; res = GetClusterNotify(hChange, varptr(lpdwNotifyKey), varptr(lpdwFilterType), varptr(lpszName), varptr(lpcchName), dwMilliseconds) ; hChange : HCHANGE -> "intptr" ; lpdwNotifyKey : UINT_PTR* out -> "intptr" ; lpdwFilterType : DWORD* out -> "intptr" ; lpszName : LPWSTR out -> "intptr" ; lpcchName : DWORD* in/out -> "intptr" ; dwMilliseconds : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procGetClusterNotify = clusapi.NewProc("GetClusterNotify")
)
// hChange (HCHANGE), lpdwNotifyKey (UINT_PTR* out), lpdwFilterType (DWORD* out), lpszName (LPWSTR out), lpcchName (DWORD* in/out), dwMilliseconds (DWORD)
r1, _, err := procGetClusterNotify.Call(
uintptr(hChange),
uintptr(lpdwNotifyKey),
uintptr(lpdwFilterType),
uintptr(lpszName),
uintptr(lpcchName),
uintptr(dwMilliseconds),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetClusterNotify(
hChange: NativeInt; // HCHANGE
lpdwNotifyKey: Pointer; // UINT_PTR* out
lpdwFilterType: Pointer; // DWORD* out
lpszName: PWideChar; // LPWSTR out
lpcchName: Pointer; // DWORD* in/out
dwMilliseconds: DWORD // DWORD
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'GetClusterNotify';result := DllCall("CLUSAPI\GetClusterNotify"
, "Ptr", hChange ; HCHANGE
, "Ptr", lpdwNotifyKey ; UINT_PTR* out
, "Ptr", lpdwFilterType ; DWORD* out
, "Ptr", lpszName ; LPWSTR out
, "Ptr", lpcchName ; DWORD* in/out
, "UInt", dwMilliseconds ; DWORD
, "UInt") ; return: DWORD●GetClusterNotify(hChange, lpdwNotifyKey, lpdwFilterType, lpszName, lpcchName, dwMilliseconds) = DLL("CLUSAPI.dll", "dword GetClusterNotify(int, void*, void*, char*, void*, dword)")
# 呼び出し: GetClusterNotify(hChange, lpdwNotifyKey, lpdwFilterType, lpszName, lpcchName, dwMilliseconds)
# hChange : HCHANGE -> "int"
# lpdwNotifyKey : UINT_PTR* out -> "void*"
# lpdwFilterType : DWORD* out -> "void*"
# lpszName : LPWSTR out -> "char*"
# lpcchName : DWORD* in/out -> "void*"
# dwMilliseconds : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。