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

ClusterAffinityRuleControl

関数
アフィニティルールに対して制御コードを発行する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ClusterAffinityRuleControl(
    HCLUSTER hCluster,
    LPCWSTR affinityRuleName,
    HNODE hHostNode,   // optional
    DWORD dwControlCode,
    void* lpInBuffer,   // optional
    DWORD cbInBufferSize,
    void* lpOutBuffer,   // optional
    DWORD cbOutBufferSize,
    DWORD* lpBytesReturned   // optional
);

パラメーター

名前方向
hClusterHCLUSTERin
affinityRuleNameLPCWSTRin
hHostNodeHNODEinoptional
dwControlCodeDWORDin
lpInBuffervoid*inoptional
cbInBufferSizeDWORDin
lpOutBuffervoid*outoptional
cbOutBufferSizeDWORDin
lpBytesReturnedDWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ClusterAffinityRuleControl(
    HCLUSTER hCluster,
    LPCWSTR affinityRuleName,
    HNODE hHostNode,   // optional
    DWORD dwControlCode,
    void* lpInBuffer,   // optional
    DWORD cbInBufferSize,
    void* lpOutBuffer,   // optional
    DWORD cbOutBufferSize,
    DWORD* lpBytesReturned   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint ClusterAffinityRuleControl(
    IntPtr hCluster,   // HCLUSTER
    [MarshalAs(UnmanagedType.LPWStr)] string affinityRuleName,   // LPCWSTR
    IntPtr hHostNode,   // HNODE optional
    uint dwControlCode,   // DWORD
    IntPtr lpInBuffer,   // void* optional
    uint cbInBufferSize,   // DWORD
    IntPtr lpOutBuffer,   // void* optional, out
    uint cbOutBufferSize,   // DWORD
    IntPtr lpBytesReturned   // DWORD* optional, out
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterAffinityRuleControl(
    hCluster As IntPtr,   ' HCLUSTER
    <MarshalAs(UnmanagedType.LPWStr)> affinityRuleName As String,   ' LPCWSTR
    hHostNode As IntPtr,   ' HNODE optional
    dwControlCode As UInteger,   ' DWORD
    lpInBuffer As IntPtr,   ' void* optional
    cbInBufferSize As UInteger,   ' DWORD
    lpOutBuffer As IntPtr,   ' void* optional, out
    cbOutBufferSize As UInteger,   ' DWORD
    lpBytesReturned As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' hCluster : HCLUSTER
' affinityRuleName : LPCWSTR
' hHostNode : HNODE optional
' dwControlCode : DWORD
' lpInBuffer : void* optional
' cbInBufferSize : DWORD
' lpOutBuffer : void* optional, out
' cbOutBufferSize : DWORD
' lpBytesReturned : DWORD* optional, out
Declare PtrSafe Function ClusterAffinityRuleControl Lib "clusapi" ( _
    ByVal hCluster As LongPtr, _
    ByVal affinityRuleName As LongPtr, _
    ByVal hHostNode As LongPtr, _
    ByVal dwControlCode As Long, _
    ByVal lpInBuffer As LongPtr, _
    ByVal cbInBufferSize As Long, _
    ByVal lpOutBuffer As LongPtr, _
    ByVal cbOutBufferSize As Long, _
    ByVal lpBytesReturned As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterAffinityRuleControl = ctypes.windll.clusapi.ClusterAffinityRuleControl
ClusterAffinityRuleControl.restype = wintypes.DWORD
ClusterAffinityRuleControl.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # affinityRuleName : LPCWSTR
    ctypes.c_ssize_t,  # hHostNode : HNODE optional
    wintypes.DWORD,  # dwControlCode : DWORD
    ctypes.POINTER(None),  # lpInBuffer : void* optional
    wintypes.DWORD,  # cbInBufferSize : DWORD
    ctypes.POINTER(None),  # lpOutBuffer : void* optional, out
    wintypes.DWORD,  # cbOutBufferSize : DWORD
    ctypes.POINTER(wintypes.DWORD),  # lpBytesReturned : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterAffinityRuleControl = Fiddle::Function.new(
  lib['ClusterAffinityRuleControl'],
  [
    Fiddle::TYPE_INTPTR_T,  # hCluster : HCLUSTER
    Fiddle::TYPE_VOIDP,  # affinityRuleName : LPCWSTR
    Fiddle::TYPE_INTPTR_T,  # hHostNode : HNODE optional
    -Fiddle::TYPE_INT,  # dwControlCode : DWORD
    Fiddle::TYPE_VOIDP,  # lpInBuffer : void* optional
    -Fiddle::TYPE_INT,  # cbInBufferSize : DWORD
    Fiddle::TYPE_VOIDP,  # lpOutBuffer : void* optional, out
    -Fiddle::TYPE_INT,  # cbOutBufferSize : DWORD
    Fiddle::TYPE_VOIDP,  # lpBytesReturned : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterAffinityRuleControl(
        hCluster: isize,  // HCLUSTER
        affinityRuleName: *const u16,  // LPCWSTR
        hHostNode: isize,  // HNODE optional
        dwControlCode: u32,  // DWORD
        lpInBuffer: *mut (),  // void* optional
        cbInBufferSize: u32,  // DWORD
        lpOutBuffer: *mut (),  // void* optional, out
        cbOutBufferSize: u32,  // DWORD
        lpBytesReturned: *mut u32  // DWORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint ClusterAffinityRuleControl(IntPtr hCluster, [MarshalAs(UnmanagedType.LPWStr)] string affinityRuleName, IntPtr hHostNode, uint dwControlCode, IntPtr lpInBuffer, uint cbInBufferSize, IntPtr lpOutBuffer, uint cbOutBufferSize, IntPtr lpBytesReturned);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterAffinityRuleControl' -Namespace Win32 -PassThru
# $api::ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
#uselib "CLUSAPI.dll"
#func global ClusterAffinityRuleControl "ClusterAffinityRuleControl" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ClusterAffinityRuleControl hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, varptr(lpBytesReturned)   ; 戻り値は stat
; hCluster : HCLUSTER -> "sptr"
; affinityRuleName : LPCWSTR -> "sptr"
; hHostNode : HNODE optional -> "sptr"
; dwControlCode : DWORD -> "sptr"
; lpInBuffer : void* optional -> "sptr"
; cbInBufferSize : DWORD -> "sptr"
; lpOutBuffer : void* optional, out -> "sptr"
; cbOutBufferSize : DWORD -> "sptr"
; lpBytesReturned : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CLUSAPI.dll"
#cfunc global ClusterAffinityRuleControl "ClusterAffinityRuleControl" sptr, wstr, sptr, int, sptr, int, sptr, int, var
; res = ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
; hCluster : HCLUSTER -> "sptr"
; affinityRuleName : LPCWSTR -> "wstr"
; hHostNode : HNODE optional -> "sptr"
; dwControlCode : DWORD -> "int"
; lpInBuffer : void* optional -> "sptr"
; cbInBufferSize : DWORD -> "int"
; lpOutBuffer : void* optional, out -> "sptr"
; cbOutBufferSize : DWORD -> "int"
; lpBytesReturned : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ClusterAffinityRuleControl(HCLUSTER hCluster, LPCWSTR affinityRuleName, HNODE hHostNode, DWORD dwControlCode, void* lpInBuffer, DWORD cbInBufferSize, void* lpOutBuffer, DWORD cbOutBufferSize, DWORD* lpBytesReturned)
#uselib "CLUSAPI.dll"
#cfunc global ClusterAffinityRuleControl "ClusterAffinityRuleControl" intptr, wstr, intptr, int, intptr, int, intptr, int, var
; res = ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
; hCluster : HCLUSTER -> "intptr"
; affinityRuleName : LPCWSTR -> "wstr"
; hHostNode : HNODE optional -> "intptr"
; dwControlCode : DWORD -> "int"
; lpInBuffer : void* optional -> "intptr"
; cbInBufferSize : DWORD -> "int"
; lpOutBuffer : void* optional, out -> "intptr"
; cbOutBufferSize : DWORD -> "int"
; lpBytesReturned : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterAffinityRuleControl = clusapi.NewProc("ClusterAffinityRuleControl")
)

// hCluster (HCLUSTER), affinityRuleName (LPCWSTR), hHostNode (HNODE optional), dwControlCode (DWORD), lpInBuffer (void* optional), cbInBufferSize (DWORD), lpOutBuffer (void* optional, out), cbOutBufferSize (DWORD), lpBytesReturned (DWORD* optional, out)
r1, _, err := procClusterAffinityRuleControl.Call(
	uintptr(hCluster),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(affinityRuleName))),
	uintptr(hHostNode),
	uintptr(dwControlCode),
	uintptr(lpInBuffer),
	uintptr(cbInBufferSize),
	uintptr(lpOutBuffer),
	uintptr(cbOutBufferSize),
	uintptr(lpBytesReturned),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ClusterAffinityRuleControl(
  hCluster: NativeInt;   // HCLUSTER
  affinityRuleName: PWideChar;   // LPCWSTR
  hHostNode: NativeInt;   // HNODE optional
  dwControlCode: DWORD;   // DWORD
  lpInBuffer: Pointer;   // void* optional
  cbInBufferSize: DWORD;   // DWORD
  lpOutBuffer: Pointer;   // void* optional, out
  cbOutBufferSize: DWORD;   // DWORD
  lpBytesReturned: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'ClusterAffinityRuleControl';
result := DllCall("CLUSAPI\ClusterAffinityRuleControl"
    , "Ptr", hCluster   ; HCLUSTER
    , "WStr", affinityRuleName   ; LPCWSTR
    , "Ptr", hHostNode   ; HNODE optional
    , "UInt", dwControlCode   ; DWORD
    , "Ptr", lpInBuffer   ; void* optional
    , "UInt", cbInBufferSize   ; DWORD
    , "Ptr", lpOutBuffer   ; void* optional, out
    , "UInt", cbOutBufferSize   ; DWORD
    , "Ptr", lpBytesReturned   ; DWORD* optional, out
    , "UInt")   ; return: DWORD
●ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned) = DLL("CLUSAPI.dll", "dword ClusterAffinityRuleControl(int, char*, int, dword, void*, dword, void*, dword, void*)")
# 呼び出し: ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
# hCluster : HCLUSTER -> "int"
# affinityRuleName : LPCWSTR -> "char*"
# hHostNode : HNODE optional -> "int"
# dwControlCode : DWORD -> "dword"
# lpInBuffer : void* optional -> "void*"
# cbInBufferSize : DWORD -> "dword"
# lpOutBuffer : void* optional, out -> "void*"
# cbOutBufferSize : DWORD -> "dword"
# lpBytesReturned : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。