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

RegisterClusterResourceTypeNotifyV2

関数
リソース種別の変更通知を登録する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2016

シグネチャ

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

DWORD RegisterClusterResourceTypeNotifyV2(
    HCHANGE hChange,
    HCLUSTER hCluster,
    LONGLONG Flags,
    LPCWSTR resTypeName,
    UINT_PTR dwNotifyKey
);

パラメーター

名前方向
hChangeHCHANGEin
hClusterHCLUSTERin
FlagsLONGLONGin
resTypeNameLPCWSTRin
dwNotifyKeyUINT_PTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RegisterClusterResourceTypeNotifyV2(
    HCHANGE hChange,
    HCLUSTER hCluster,
    LONGLONG Flags,
    LPCWSTR resTypeName,
    UINT_PTR dwNotifyKey
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint RegisterClusterResourceTypeNotifyV2(
    IntPtr hChange,   // HCHANGE
    IntPtr hCluster,   // HCLUSTER
    long Flags,   // LONGLONG
    [MarshalAs(UnmanagedType.LPWStr)] string resTypeName,   // LPCWSTR
    UIntPtr dwNotifyKey   // UINT_PTR
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function RegisterClusterResourceTypeNotifyV2(
    hChange As IntPtr,   ' HCHANGE
    hCluster As IntPtr,   ' HCLUSTER
    Flags As Long,   ' LONGLONG
    <MarshalAs(UnmanagedType.LPWStr)> resTypeName As String,   ' LPCWSTR
    dwNotifyKey As UIntPtr   ' UINT_PTR
) As UInteger
End Function
' hChange : HCHANGE
' hCluster : HCLUSTER
' Flags : LONGLONG
' resTypeName : LPCWSTR
' dwNotifyKey : UINT_PTR
Declare PtrSafe Function RegisterClusterResourceTypeNotifyV2 Lib "clusapi" ( _
    ByVal hChange As LongPtr, _
    ByVal hCluster As LongPtr, _
    ByVal Flags As LongLong, _
    ByVal resTypeName 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

RegisterClusterResourceTypeNotifyV2 = ctypes.windll.clusapi.RegisterClusterResourceTypeNotifyV2
RegisterClusterResourceTypeNotifyV2.restype = wintypes.DWORD
RegisterClusterResourceTypeNotifyV2.argtypes = [
    ctypes.c_ssize_t,  # hChange : HCHANGE
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    ctypes.c_longlong,  # Flags : LONGLONG
    wintypes.LPCWSTR,  # resTypeName : LPCWSTR
    ctypes.c_size_t,  # dwNotifyKey : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
RegisterClusterResourceTypeNotifyV2 = Fiddle::Function.new(
  lib['RegisterClusterResourceTypeNotifyV2'],
  [
    Fiddle::TYPE_INTPTR_T,  # hChange : HCHANGE
    Fiddle::TYPE_INTPTR_T,  # hCluster : HCLUSTER
    Fiddle::TYPE_LONG_LONG,  # Flags : LONGLONG
    Fiddle::TYPE_VOIDP,  # resTypeName : LPCWSTR
    Fiddle::TYPE_UINTPTR_T,  # dwNotifyKey : UINT_PTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn RegisterClusterResourceTypeNotifyV2(
        hChange: isize,  // HCHANGE
        hCluster: isize,  // HCLUSTER
        Flags: i64,  // LONGLONG
        resTypeName: *const u16,  // LPCWSTR
        dwNotifyKey: usize  // UINT_PTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint RegisterClusterResourceTypeNotifyV2(IntPtr hChange, IntPtr hCluster, long Flags, [MarshalAs(UnmanagedType.LPWStr)] string resTypeName, UIntPtr dwNotifyKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_RegisterClusterResourceTypeNotifyV2' -Namespace Win32 -PassThru
# $api::RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
#uselib "CLUSAPI.dll"
#func global RegisterClusterResourceTypeNotifyV2 "RegisterClusterResourceTypeNotifyV2" sptr, sptr, sptr, sptr, sptr
; RegisterClusterResourceTypeNotifyV2 hChange, hCluster, Flags, resTypeName, dwNotifyKey   ; 戻り値は stat
; hChange : HCHANGE -> "sptr"
; hCluster : HCLUSTER -> "sptr"
; Flags : LONGLONG -> "sptr"
; resTypeName : LPCWSTR -> "sptr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterResourceTypeNotifyV2 "RegisterClusterResourceTypeNotifyV2" sptr, sptr, int64, wstr, sptr
; res = RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
; hChange : HCHANGE -> "sptr"
; hCluster : HCLUSTER -> "sptr"
; Flags : LONGLONG -> "int64"
; resTypeName : LPCWSTR -> "wstr"
; dwNotifyKey : UINT_PTR -> "sptr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; DWORD RegisterClusterResourceTypeNotifyV2(HCHANGE hChange, HCLUSTER hCluster, LONGLONG Flags, LPCWSTR resTypeName, UINT_PTR dwNotifyKey)
#uselib "CLUSAPI.dll"
#cfunc global RegisterClusterResourceTypeNotifyV2 "RegisterClusterResourceTypeNotifyV2" intptr, intptr, int64, wstr, intptr
; res = RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
; hChange : HCHANGE -> "intptr"
; hCluster : HCLUSTER -> "intptr"
; Flags : LONGLONG -> "int64"
; resTypeName : LPCWSTR -> "wstr"
; dwNotifyKey : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procRegisterClusterResourceTypeNotifyV2 = clusapi.NewProc("RegisterClusterResourceTypeNotifyV2")
)

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