ホーム › Networking.Clustering › RegisterClusterResourceTypeNotifyV2
RegisterClusterResourceTypeNotifyV2
関数リソース種別の変更通知を登録する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
DWORD RegisterClusterResourceTypeNotifyV2(
HCHANGE hChange,
HCLUSTER hCluster,
LONGLONG Flags,
LPCWSTR resTypeName,
UINT_PTR dwNotifyKey
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hChange | HCHANGE | in | 通知を受け取る変更ポートのハンドル。 |
| hCluster | HCLUSTER | in | 通知登録の対象クラスターのハンドル。 |
| Flags | LONGLONG | in | 受信する通知イベントの種別を示すLONGLONGのビットフラグ。 |
| resTypeName | LPCWSTR | in | 通知対象のリソース種別名を示すワイド文字列。 |
| dwNotifyKey | UINT_PTR | in | 通知時に返される呼び出し側定義のキー値。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "clusapi" fn RegisterClusterResourceTypeNotifyV2(
hChange: isize, // HCHANGE
hCluster: isize, // HCLUSTER
Flags: i64, // LONGLONG
resTypeName: [*c]const u16, // LPCWSTR
dwNotifyKey: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) u32;proc RegisterClusterResourceTypeNotifyV2(
hChange: int, # HCHANGE
hCluster: int, # HCLUSTER
Flags: int64, # LONGLONG
resTypeName: WideCString, # LPCWSTR
dwNotifyKey: uint # UINT_PTR
): uint32 {.importc: "RegisterClusterResourceTypeNotifyV2", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
uint RegisterClusterResourceTypeNotifyV2(
ptrdiff_t hChange, // HCHANGE
ptrdiff_t hCluster, // HCLUSTER
long Flags, // LONGLONG
const(wchar)* resTypeName, // LPCWSTR
size_t dwNotifyKey // UINT_PTR
);ccall((:RegisterClusterResourceTypeNotifyV2, "CLUSAPI.dll"), stdcall, UInt32,
(Int, Int, Int64, Cwstring, Csize_t),
hChange, hCluster, Flags, resTypeName, dwNotifyKey)
# hChange : HCHANGE -> Int
# hCluster : HCLUSTER -> Int
# Flags : LONGLONG -> Int64
# resTypeName : LPCWSTR -> Cwstring
# dwNotifyKey : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RegisterClusterResourceTypeNotifyV2(
intptr_t hChange,
intptr_t hCluster,
int64_t Flags,
const uint16_t* resTypeName,
uintptr_t dwNotifyKey);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
-- hChange : HCHANGE
-- hCluster : HCLUSTER
-- Flags : LONGLONG
-- resTypeName : LPCWSTR
-- dwNotifyKey : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const RegisterClusterResourceTypeNotifyV2 = lib.func('__stdcall', 'RegisterClusterResourceTypeNotifyV2', 'uint32_t', ['intptr_t', 'intptr_t', 'int64_t', 'str16', 'uintptr_t']);
// RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
// hChange : HCHANGE -> 'intptr_t'
// hCluster : HCLUSTER -> 'intptr_t'
// Flags : LONGLONG -> 'int64_t'
// resTypeName : LPCWSTR -> 'str16'
// dwNotifyKey : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
RegisterClusterResourceTypeNotifyV2: { parameters: ["isize", "isize", "i64", "buffer", "usize"], result: "u32" },
});
// lib.symbols.RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey)
// hChange : HCHANGE -> "isize"
// hCluster : HCLUSTER -> "isize"
// Flags : LONGLONG -> "i64"
// resTypeName : LPCWSTR -> "buffer"
// dwNotifyKey : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RegisterClusterResourceTypeNotifyV2(
intptr_t hChange,
intptr_t hCluster,
int64_t Flags,
const uint16_t* resTypeName,
size_t dwNotifyKey);
C, "CLUSAPI.dll");
// $ffi->RegisterClusterResourceTypeNotifyV2(hChange, hCluster, Flags, resTypeName, dwNotifyKey);
// hChange : HCHANGE
// hCluster : HCLUSTER
// Flags : LONGLONG
// resTypeName : LPCWSTR
// 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 RegisterClusterResourceTypeNotifyV2(
long hChange, // HCHANGE
long hCluster, // HCLUSTER
long Flags, // LONGLONG
WString resTypeName, // LPCWSTR
long dwNotifyKey // UINT_PTR
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun RegisterClusterResourceTypeNotifyV2 = RegisterClusterResourceTypeNotifyV2(
hChange : LibC::SSizeT, # HCHANGE
hCluster : LibC::SSizeT, # HCLUSTER
Flags : Int64, # LONGLONG
resTypeName : UInt16*, # LPCWSTR
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 RegisterClusterResourceTypeNotifyV2Native = Uint32 Function(IntPtr, IntPtr, Int64, Pointer<Utf16>, UintPtr);
typedef RegisterClusterResourceTypeNotifyV2Dart = int Function(int, int, int, Pointer<Utf16>, int);
final RegisterClusterResourceTypeNotifyV2 = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<RegisterClusterResourceTypeNotifyV2Native, RegisterClusterResourceTypeNotifyV2Dart>('RegisterClusterResourceTypeNotifyV2');
// hChange : HCHANGE -> IntPtr
// hCluster : HCLUSTER -> IntPtr
// Flags : LONGLONG -> Int64
// resTypeName : LPCWSTR -> Pointer<Utf16>
// dwNotifyKey : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegisterClusterResourceTypeNotifyV2"
c_RegisterClusterResourceTypeNotifyV2 :: CIntPtr -> CIntPtr -> Int64 -> CWString -> CUIntPtr -> IO Word32
-- hChange : HCHANGE -> CIntPtr
-- hCluster : HCLUSTER -> CIntPtr
-- Flags : LONGLONG -> Int64
-- resTypeName : LPCWSTR -> CWString
-- dwNotifyKey : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let registerclusterresourcetypenotifyv2 =
foreign "RegisterClusterResourceTypeNotifyV2"
(intptr_t @-> intptr_t @-> int64_t @-> (ptr uint16_t) @-> size_t @-> returning uint32_t)
(* hChange : HCHANGE -> intptr_t *)
(* hCluster : HCLUSTER -> intptr_t *)
(* Flags : LONGLONG -> int64_t *)
(* resTypeName : LPCWSTR -> (ptr uint16_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 ("RegisterClusterResourceTypeNotifyV2" register-cluster-resource-type-notify-v2 :convention :stdcall) :uint32
(h-change :int64) ; HCHANGE
(h-cluster :int64) ; HCLUSTER
(flags :int64) ; LONGLONG
(res-type-name (:string :encoding :utf-16le)) ; LPCWSTR
(dw-notify-key :uint64)) ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegisterClusterResourceTypeNotifyV2 = Win32::API::More->new('CLUSAPI',
'DWORD RegisterClusterResourceTypeNotifyV2(LPARAM hChange, LPARAM hCluster, INT64 Flags, LPCWSTR resTypeName, WPARAM dwNotifyKey)');
# my $ret = $RegisterClusterResourceTypeNotifyV2->Call($hChange, $hCluster, $Flags, $resTypeName, $dwNotifyKey);
# hChange : HCHANGE -> LPARAM
# hCluster : HCLUSTER -> LPARAM
# Flags : LONGLONG -> INT64
# resTypeName : LPCWSTR -> LPCWSTR
# dwNotifyKey : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。