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

ClusterAddGroupToAffinityRule

関数
アフィニティルールにクラスターグループを追加する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ClusterAddGroupToAffinityRule(
    HCLUSTER hCluster,
    LPCWSTR ruleName,
    HGROUP hGroup
);

パラメーター

名前方向
hClusterHCLUSTERin
ruleNameLPCWSTRin
hGroupHGROUPin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ClusterAddGroupToAffinityRule(
    HCLUSTER hCluster,
    LPCWSTR ruleName,
    HGROUP hGroup
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint ClusterAddGroupToAffinityRule(
    IntPtr hCluster,   // HCLUSTER
    [MarshalAs(UnmanagedType.LPWStr)] string ruleName,   // LPCWSTR
    IntPtr hGroup   // HGROUP
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterAddGroupToAffinityRule(
    hCluster As IntPtr,   ' HCLUSTER
    <MarshalAs(UnmanagedType.LPWStr)> ruleName As String,   ' LPCWSTR
    hGroup As IntPtr   ' HGROUP
) As UInteger
End Function
' hCluster : HCLUSTER
' ruleName : LPCWSTR
' hGroup : HGROUP
Declare PtrSafe Function ClusterAddGroupToAffinityRule Lib "clusapi" ( _
    ByVal hCluster As LongPtr, _
    ByVal ruleName As LongPtr, _
    ByVal hGroup As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterAddGroupToAffinityRule = ctypes.windll.clusapi.ClusterAddGroupToAffinityRule
ClusterAddGroupToAffinityRule.restype = wintypes.DWORD
ClusterAddGroupToAffinityRule.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # ruleName : LPCWSTR
    ctypes.c_ssize_t,  # hGroup : HGROUP
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterAddGroupToAffinityRule = Fiddle::Function.new(
  lib['ClusterAddGroupToAffinityRule'],
  [
    Fiddle::TYPE_INTPTR_T,  # hCluster : HCLUSTER
    Fiddle::TYPE_VOIDP,  # ruleName : LPCWSTR
    Fiddle::TYPE_INTPTR_T,  # hGroup : HGROUP
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterAddGroupToAffinityRule(
        hCluster: isize,  // HCLUSTER
        ruleName: *const u16,  // LPCWSTR
        hGroup: isize  // HGROUP
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint ClusterAddGroupToAffinityRule(IntPtr hCluster, [MarshalAs(UnmanagedType.LPWStr)] string ruleName, IntPtr hGroup);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterAddGroupToAffinityRule' -Namespace Win32 -PassThru
# $api::ClusterAddGroupToAffinityRule(hCluster, ruleName, hGroup)
#uselib "CLUSAPI.dll"
#func global ClusterAddGroupToAffinityRule "ClusterAddGroupToAffinityRule" sptr, sptr, sptr
; ClusterAddGroupToAffinityRule hCluster, ruleName, hGroup   ; 戻り値は stat
; hCluster : HCLUSTER -> "sptr"
; ruleName : LPCWSTR -> "sptr"
; hGroup : HGROUP -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global ClusterAddGroupToAffinityRule "ClusterAddGroupToAffinityRule" sptr, wstr, sptr
; res = ClusterAddGroupToAffinityRule(hCluster, ruleName, hGroup)
; hCluster : HCLUSTER -> "sptr"
; ruleName : LPCWSTR -> "wstr"
; hGroup : HGROUP -> "sptr"
; DWORD ClusterAddGroupToAffinityRule(HCLUSTER hCluster, LPCWSTR ruleName, HGROUP hGroup)
#uselib "CLUSAPI.dll"
#cfunc global ClusterAddGroupToAffinityRule "ClusterAddGroupToAffinityRule" intptr, wstr, intptr
; res = ClusterAddGroupToAffinityRule(hCluster, ruleName, hGroup)
; hCluster : HCLUSTER -> "intptr"
; ruleName : LPCWSTR -> "wstr"
; hGroup : HGROUP -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterAddGroupToAffinityRule = clusapi.NewProc("ClusterAddGroupToAffinityRule")
)

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