ホーム › Networking.Clustering › ClusterAffinityRuleControl
ClusterAffinityRuleControl
関数アフィニティルールに対して制御コードを発行する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hCluster | HCLUSTER | in | 対象クラスタへのハンドル。 |
| affinityRuleName | LPCWSTR | in | 制御対象のアフィニティルール名を指すワイド文字列。 |
| hHostNode | HNODE | inoptional | 制御を実行するホストノードへのハンドル。任意ノードでよければNULL可。 |
| dwControlCode | DWORD | in | 実行するアフィニティルール制御コード。 |
| lpInBuffer | void* | inoptional | 制御コードへの入力データバッファへのポインタ。不要ならNULL可。 |
| cbInBufferSize | DWORD | in | 入力バッファのサイズ(バイト)。 |
| lpOutBuffer | void* | outoptional | 制御結果を受け取る出力バッファへのポインタ。不要ならNULL可。 |
| cbOutBufferSize | DWORD | in | 出力バッファのサイズ(バイト)。 |
| lpBytesReturned | DWORD* | 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 方式にも切替可。#uselib "CLUSAPI.dll" #cfunc global ClusterAffinityRuleControl "ClusterAffinityRuleControl" sptr, wstr, sptr, int, sptr, int, sptr, int, sptr ; res = ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, varptr(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 -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, varptr(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 -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "clusapi" fn ClusterAffinityRuleControl(
hCluster: isize, // HCLUSTER
affinityRuleName: [*c]const u16, // LPCWSTR
hHostNode: isize, // HNODE optional
dwControlCode: u32, // DWORD
lpInBuffer: ?*anyopaque, // void* optional
cbInBufferSize: u32, // DWORD
lpOutBuffer: ?*anyopaque, // void* optional, out
cbOutBufferSize: u32, // DWORD
lpBytesReturned: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) u32;proc ClusterAffinityRuleControl(
hCluster: int, # HCLUSTER
affinityRuleName: WideCString, # LPCWSTR
hHostNode: int, # HNODE optional
dwControlCode: uint32, # DWORD
lpInBuffer: pointer, # void* optional
cbInBufferSize: uint32, # DWORD
lpOutBuffer: pointer, # void* optional, out
cbOutBufferSize: uint32, # DWORD
lpBytesReturned: ptr uint32 # DWORD* optional, out
): uint32 {.importc: "ClusterAffinityRuleControl", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
uint ClusterAffinityRuleControl(
ptrdiff_t hCluster, // HCLUSTER
const(wchar)* affinityRuleName, // LPCWSTR
ptrdiff_t hHostNode, // HNODE optional
uint dwControlCode, // DWORD
void* lpInBuffer, // void* optional
uint cbInBufferSize, // DWORD
void* lpOutBuffer, // void* optional, out
uint cbOutBufferSize, // DWORD
uint* lpBytesReturned // DWORD* optional, out
);ccall((:ClusterAffinityRuleControl, "CLUSAPI.dll"), stdcall, UInt32,
(Int, Cwstring, Int, UInt32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}),
hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
# hCluster : HCLUSTER -> Int
# affinityRuleName : LPCWSTR -> Cwstring
# hHostNode : HNODE optional -> Int
# dwControlCode : DWORD -> UInt32
# lpInBuffer : void* optional -> Ptr{Cvoid}
# cbInBufferSize : DWORD -> UInt32
# lpOutBuffer : void* optional, out -> Ptr{Cvoid}
# cbOutBufferSize : DWORD -> UInt32
# lpBytesReturned : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ClusterAffinityRuleControl(
intptr_t hCluster,
const uint16_t* affinityRuleName,
intptr_t hHostNode,
uint32_t dwControlCode,
void* lpInBuffer,
uint32_t cbInBufferSize,
void* lpOutBuffer,
uint32_t cbOutBufferSize,
uint32_t* lpBytesReturned);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
-- hCluster : HCLUSTER
-- affinityRuleName : LPCWSTR
-- hHostNode : HNODE optional
-- dwControlCode : DWORD
-- lpInBuffer : void* optional
-- cbInBufferSize : DWORD
-- lpOutBuffer : void* optional, out
-- cbOutBufferSize : DWORD
-- lpBytesReturned : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterAffinityRuleControl = lib.func('__stdcall', 'ClusterAffinityRuleControl', 'uint32_t', ['intptr_t', 'str16', 'intptr_t', 'uint32_t', 'void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t *']);
// ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
// hCluster : HCLUSTER -> 'intptr_t'
// affinityRuleName : LPCWSTR -> 'str16'
// hHostNode : HNODE optional -> 'intptr_t'
// dwControlCode : DWORD -> 'uint32_t'
// lpInBuffer : void* optional -> 'void *'
// cbInBufferSize : DWORD -> 'uint32_t'
// lpOutBuffer : void* optional, out -> 'void *'
// cbOutBufferSize : DWORD -> 'uint32_t'
// lpBytesReturned : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterAffinityRuleControl: { parameters: ["isize", "buffer", "isize", "u32", "pointer", "u32", "pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned)
// hCluster : HCLUSTER -> "isize"
// affinityRuleName : LPCWSTR -> "buffer"
// hHostNode : HNODE optional -> "isize"
// dwControlCode : DWORD -> "u32"
// lpInBuffer : void* optional -> "pointer"
// cbInBufferSize : DWORD -> "u32"
// lpOutBuffer : void* optional, out -> "pointer"
// cbOutBufferSize : DWORD -> "u32"
// lpBytesReturned : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ClusterAffinityRuleControl(
intptr_t hCluster,
const uint16_t* affinityRuleName,
intptr_t hHostNode,
uint32_t dwControlCode,
void* lpInBuffer,
uint32_t cbInBufferSize,
void* lpOutBuffer,
uint32_t cbOutBufferSize,
uint32_t* lpBytesReturned);
C, "CLUSAPI.dll");
// $ffi->ClusterAffinityRuleControl(hCluster, affinityRuleName, hHostNode, dwControlCode, lpInBuffer, cbInBufferSize, lpOutBuffer, cbOutBufferSize, lpBytesReturned);
// hCluster : HCLUSTER
// affinityRuleName : LPCWSTR
// hHostNode : HNODE optional
// dwControlCode : DWORD
// lpInBuffer : void* optional
// cbInBufferSize : DWORD
// lpOutBuffer : void* optional, out
// cbOutBufferSize : DWORD
// lpBytesReturned : DWORD* optional, out
// 構造体/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 ClusterAffinityRuleControl(
long hCluster, // HCLUSTER
WString affinityRuleName, // LPCWSTR
long hHostNode, // HNODE optional
int dwControlCode, // DWORD
Pointer lpInBuffer, // void* optional
int cbInBufferSize, // DWORD
Pointer lpOutBuffer, // void* optional, out
int cbOutBufferSize, // DWORD
IntByReference lpBytesReturned // DWORD* optional, out
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterAffinityRuleControl = ClusterAffinityRuleControl(
hCluster : LibC::SSizeT, # HCLUSTER
affinityRuleName : UInt16*, # LPCWSTR
hHostNode : LibC::SSizeT, # HNODE optional
dwControlCode : UInt32, # DWORD
lpInBuffer : Void*, # void* optional
cbInBufferSize : UInt32, # DWORD
lpOutBuffer : Void*, # void* optional, out
cbOutBufferSize : UInt32, # DWORD
lpBytesReturned : UInt32* # DWORD* optional, out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterAffinityRuleControlNative = Uint32 Function(IntPtr, Pointer<Utf16>, IntPtr, Uint32, Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Uint32>);
typedef ClusterAffinityRuleControlDart = int Function(int, Pointer<Utf16>, int, int, Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>);
final ClusterAffinityRuleControl = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterAffinityRuleControlNative, ClusterAffinityRuleControlDart>('ClusterAffinityRuleControl');
// hCluster : HCLUSTER -> IntPtr
// affinityRuleName : LPCWSTR -> Pointer<Utf16>
// hHostNode : HNODE optional -> IntPtr
// dwControlCode : DWORD -> Uint32
// lpInBuffer : void* optional -> Pointer<Void>
// cbInBufferSize : DWORD -> Uint32
// lpOutBuffer : void* optional, out -> Pointer<Void>
// cbOutBufferSize : DWORD -> Uint32
// lpBytesReturned : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterAffinityRuleControl"
c_ClusterAffinityRuleControl :: CIntPtr -> CWString -> CIntPtr -> Word32 -> Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr Word32 -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- affinityRuleName : LPCWSTR -> CWString
-- hHostNode : HNODE optional -> CIntPtr
-- dwControlCode : DWORD -> Word32
-- lpInBuffer : void* optional -> Ptr ()
-- cbInBufferSize : DWORD -> Word32
-- lpOutBuffer : void* optional, out -> Ptr ()
-- cbOutBufferSize : DWORD -> Word32
-- lpBytesReturned : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusteraffinityrulecontrol =
foreign "ClusterAffinityRuleControl"
(intptr_t @-> (ptr uint16_t) @-> intptr_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* affinityRuleName : LPCWSTR -> (ptr uint16_t) *)
(* hHostNode : HNODE optional -> intptr_t *)
(* dwControlCode : DWORD -> uint32_t *)
(* lpInBuffer : void* optional -> (ptr void) *)
(* cbInBufferSize : DWORD -> uint32_t *)
(* lpOutBuffer : void* optional, out -> (ptr void) *)
(* cbOutBufferSize : DWORD -> uint32_t *)
(* lpBytesReturned : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterAffinityRuleControl" cluster-affinity-rule-control :convention :stdcall) :uint32
(h-cluster :int64) ; HCLUSTER
(affinity-rule-name (:string :encoding :utf-16le)) ; LPCWSTR
(h-host-node :int64) ; HNODE optional
(dw-control-code :uint32) ; DWORD
(lp-in-buffer :pointer) ; void* optional
(cb-in-buffer-size :uint32) ; DWORD
(lp-out-buffer :pointer) ; void* optional, out
(cb-out-buffer-size :uint32) ; DWORD
(lp-bytes-returned :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterAffinityRuleControl = Win32::API::More->new('CLUSAPI',
'DWORD ClusterAffinityRuleControl(LPARAM hCluster, LPCWSTR affinityRuleName, LPARAM hHostNode, DWORD dwControlCode, LPVOID lpInBuffer, DWORD cbInBufferSize, LPVOID lpOutBuffer, DWORD cbOutBufferSize, LPVOID lpBytesReturned)');
# my $ret = $ClusterAffinityRuleControl->Call($hCluster, $affinityRuleName, $hHostNode, $dwControlCode, $lpInBuffer, $cbInBufferSize, $lpOutBuffer, $cbOutBufferSize, $lpBytesReturned);
# hCluster : HCLUSTER -> LPARAM
# affinityRuleName : LPCWSTR -> LPCWSTR
# hHostNode : HNODE optional -> LPARAM
# dwControlCode : DWORD -> DWORD
# lpInBuffer : void* optional -> LPVOID
# cbInBufferSize : DWORD -> DWORD
# lpOutBuffer : void* optional, out -> LPVOID
# cbOutBufferSize : DWORD -> DWORD
# lpBytesReturned : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。