ホーム › Networking.Clustering › ClusterControlEx
ClusterControlEx
関数理由を付与してクラスター制御コードを発行する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
DWORD ClusterControlEx(
HCLUSTER hCluster,
HNODE hHostNode, // optional
DWORD dwControlCode,
void* lpInBuffer, // optional
DWORD nInBufferSize,
void* lpOutBuffer, // optional
DWORD nOutBufferSize,
DWORD* lpBytesReturned, // optional
LPCWSTR lpszReason // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hCluster | HCLUSTER | in | 対象クラスタへのハンドル。 |
| hHostNode | HNODE | inoptional | 制御を実行するホストノードへのハンドル。任意ノードでよければNULL可。 |
| dwControlCode | DWORD | in | 実行するクラスタ制御コード(CLUSCTL_CLUSTER_*)。 |
| lpInBuffer | void* | inoptional | 制御コードへの入力データバッファへのポインタ。不要ならNULL可。 |
| nInBufferSize | DWORD | in | 入力バッファのサイズ(バイト)。 |
| lpOutBuffer | void* | outoptional | 制御結果を受け取る出力バッファへのポインタ。不要ならNULL可。 |
| nOutBufferSize | DWORD | in | 出力バッファのサイズ(バイト)。 |
| lpBytesReturned | DWORD* | outoptional | 出力バッファに書き込まれたバイト数を受け取る出力。 |
| lpszReason | LPCWSTR | inoptional | 操作理由を記録するためのワイド文字列。監査用で不要ならNULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
DWORD ClusterControlEx(
HCLUSTER hCluster,
HNODE hHostNode, // optional
DWORD dwControlCode,
void* lpInBuffer, // optional
DWORD nInBufferSize,
void* lpOutBuffer, // optional
DWORD nOutBufferSize,
DWORD* lpBytesReturned, // optional
LPCWSTR lpszReason // optional
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint ClusterControlEx(
IntPtr hCluster, // HCLUSTER
IntPtr hHostNode, // HNODE optional
uint dwControlCode, // DWORD
IntPtr lpInBuffer, // void* optional
uint nInBufferSize, // DWORD
IntPtr lpOutBuffer, // void* optional, out
uint nOutBufferSize, // DWORD
IntPtr lpBytesReturned, // DWORD* optional, out
[MarshalAs(UnmanagedType.LPWStr)] string lpszReason // LPCWSTR optional
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterControlEx(
hCluster As IntPtr, ' HCLUSTER
hHostNode As IntPtr, ' HNODE optional
dwControlCode As UInteger, ' DWORD
lpInBuffer As IntPtr, ' void* optional
nInBufferSize As UInteger, ' DWORD
lpOutBuffer As IntPtr, ' void* optional, out
nOutBufferSize As UInteger, ' DWORD
lpBytesReturned As IntPtr, ' DWORD* optional, out
<MarshalAs(UnmanagedType.LPWStr)> lpszReason As String ' LPCWSTR optional
) As UInteger
End Function' hCluster : HCLUSTER
' hHostNode : HNODE optional
' dwControlCode : DWORD
' lpInBuffer : void* optional
' nInBufferSize : DWORD
' lpOutBuffer : void* optional, out
' nOutBufferSize : DWORD
' lpBytesReturned : DWORD* optional, out
' lpszReason : LPCWSTR optional
Declare PtrSafe Function ClusterControlEx Lib "clusapi" ( _
ByVal hCluster As LongPtr, _
ByVal hHostNode As LongPtr, _
ByVal dwControlCode As Long, _
ByVal lpInBuffer As LongPtr, _
ByVal nInBufferSize As Long, _
ByVal lpOutBuffer As LongPtr, _
ByVal nOutBufferSize As Long, _
ByVal lpBytesReturned As LongPtr, _
ByVal lpszReason As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterControlEx = ctypes.windll.clusapi.ClusterControlEx
ClusterControlEx.restype = wintypes.DWORD
ClusterControlEx.argtypes = [
ctypes.c_ssize_t, # hCluster : HCLUSTER
ctypes.c_ssize_t, # hHostNode : HNODE optional
wintypes.DWORD, # dwControlCode : DWORD
ctypes.POINTER(None), # lpInBuffer : void* optional
wintypes.DWORD, # nInBufferSize : DWORD
ctypes.POINTER(None), # lpOutBuffer : void* optional, out
wintypes.DWORD, # nOutBufferSize : DWORD
ctypes.POINTER(wintypes.DWORD), # lpBytesReturned : DWORD* optional, out
wintypes.LPCWSTR, # lpszReason : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterControlEx = Fiddle::Function.new(
lib['ClusterControlEx'],
[
Fiddle::TYPE_INTPTR_T, # hCluster : HCLUSTER
Fiddle::TYPE_INTPTR_T, # hHostNode : HNODE optional
-Fiddle::TYPE_INT, # dwControlCode : DWORD
Fiddle::TYPE_VOIDP, # lpInBuffer : void* optional
-Fiddle::TYPE_INT, # nInBufferSize : DWORD
Fiddle::TYPE_VOIDP, # lpOutBuffer : void* optional, out
-Fiddle::TYPE_INT, # nOutBufferSize : DWORD
Fiddle::TYPE_VOIDP, # lpBytesReturned : DWORD* optional, out
Fiddle::TYPE_VOIDP, # lpszReason : LPCWSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn ClusterControlEx(
hCluster: isize, // HCLUSTER
hHostNode: isize, // HNODE optional
dwControlCode: u32, // DWORD
lpInBuffer: *mut (), // void* optional
nInBufferSize: u32, // DWORD
lpOutBuffer: *mut (), // void* optional, out
nOutBufferSize: u32, // DWORD
lpBytesReturned: *mut u32, // DWORD* optional, out
lpszReason: *const u16 // LPCWSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint ClusterControlEx(IntPtr hCluster, IntPtr hHostNode, uint dwControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, IntPtr lpBytesReturned, [MarshalAs(UnmanagedType.LPWStr)] string lpszReason);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterControlEx' -Namespace Win32 -PassThru
# $api::ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)#uselib "CLUSAPI.dll"
#func global ClusterControlEx "ClusterControlEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ClusterControlEx hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, varptr(lpBytesReturned), lpszReason ; 戻り値は stat
; hCluster : HCLUSTER -> "sptr"
; hHostNode : HNODE optional -> "sptr"
; dwControlCode : DWORD -> "sptr"
; lpInBuffer : void* optional -> "sptr"
; nInBufferSize : DWORD -> "sptr"
; lpOutBuffer : void* optional, out -> "sptr"
; nOutBufferSize : DWORD -> "sptr"
; lpBytesReturned : DWORD* optional, out -> "sptr"
; lpszReason : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CLUSAPI.dll" #cfunc global ClusterControlEx "ClusterControlEx" sptr, sptr, int, sptr, int, sptr, int, var, wstr ; res = ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason) ; hCluster : HCLUSTER -> "sptr" ; hHostNode : HNODE optional -> "sptr" ; dwControlCode : DWORD -> "int" ; lpInBuffer : void* optional -> "sptr" ; nInBufferSize : DWORD -> "int" ; lpOutBuffer : void* optional, out -> "sptr" ; nOutBufferSize : DWORD -> "int" ; lpBytesReturned : DWORD* optional, out -> "var" ; lpszReason : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CLUSAPI.dll" #cfunc global ClusterControlEx "ClusterControlEx" sptr, sptr, int, sptr, int, sptr, int, sptr, wstr ; res = ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, varptr(lpBytesReturned), lpszReason) ; hCluster : HCLUSTER -> "sptr" ; hHostNode : HNODE optional -> "sptr" ; dwControlCode : DWORD -> "int" ; lpInBuffer : void* optional -> "sptr" ; nInBufferSize : DWORD -> "int" ; lpOutBuffer : void* optional, out -> "sptr" ; nOutBufferSize : DWORD -> "int" ; lpBytesReturned : DWORD* optional, out -> "sptr" ; lpszReason : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ClusterControlEx(HCLUSTER hCluster, HNODE hHostNode, DWORD dwControlCode, void* lpInBuffer, DWORD nInBufferSize, void* lpOutBuffer, DWORD nOutBufferSize, DWORD* lpBytesReturned, LPCWSTR lpszReason) #uselib "CLUSAPI.dll" #cfunc global ClusterControlEx "ClusterControlEx" intptr, intptr, int, intptr, int, intptr, int, var, wstr ; res = ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason) ; hCluster : HCLUSTER -> "intptr" ; hHostNode : HNODE optional -> "intptr" ; dwControlCode : DWORD -> "int" ; lpInBuffer : void* optional -> "intptr" ; nInBufferSize : DWORD -> "int" ; lpOutBuffer : void* optional, out -> "intptr" ; nOutBufferSize : DWORD -> "int" ; lpBytesReturned : DWORD* optional, out -> "var" ; lpszReason : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ClusterControlEx(HCLUSTER hCluster, HNODE hHostNode, DWORD dwControlCode, void* lpInBuffer, DWORD nInBufferSize, void* lpOutBuffer, DWORD nOutBufferSize, DWORD* lpBytesReturned, LPCWSTR lpszReason) #uselib "CLUSAPI.dll" #cfunc global ClusterControlEx "ClusterControlEx" intptr, intptr, int, intptr, int, intptr, int, intptr, wstr ; res = ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, varptr(lpBytesReturned), lpszReason) ; hCluster : HCLUSTER -> "intptr" ; hHostNode : HNODE optional -> "intptr" ; dwControlCode : DWORD -> "int" ; lpInBuffer : void* optional -> "intptr" ; nInBufferSize : DWORD -> "int" ; lpOutBuffer : void* optional, out -> "intptr" ; nOutBufferSize : DWORD -> "int" ; lpBytesReturned : DWORD* optional, out -> "intptr" ; lpszReason : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procClusterControlEx = clusapi.NewProc("ClusterControlEx")
)
// hCluster (HCLUSTER), hHostNode (HNODE optional), dwControlCode (DWORD), lpInBuffer (void* optional), nInBufferSize (DWORD), lpOutBuffer (void* optional, out), nOutBufferSize (DWORD), lpBytesReturned (DWORD* optional, out), lpszReason (LPCWSTR optional)
r1, _, err := procClusterControlEx.Call(
uintptr(hCluster),
uintptr(hHostNode),
uintptr(dwControlCode),
uintptr(lpInBuffer),
uintptr(nInBufferSize),
uintptr(lpOutBuffer),
uintptr(nOutBufferSize),
uintptr(lpBytesReturned),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszReason))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ClusterControlEx(
hCluster: NativeInt; // HCLUSTER
hHostNode: NativeInt; // HNODE optional
dwControlCode: DWORD; // DWORD
lpInBuffer: Pointer; // void* optional
nInBufferSize: DWORD; // DWORD
lpOutBuffer: Pointer; // void* optional, out
nOutBufferSize: DWORD; // DWORD
lpBytesReturned: Pointer; // DWORD* optional, out
lpszReason: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'ClusterControlEx';result := DllCall("CLUSAPI\ClusterControlEx"
, "Ptr", hCluster ; HCLUSTER
, "Ptr", hHostNode ; HNODE optional
, "UInt", dwControlCode ; DWORD
, "Ptr", lpInBuffer ; void* optional
, "UInt", nInBufferSize ; DWORD
, "Ptr", lpOutBuffer ; void* optional, out
, "UInt", nOutBufferSize ; DWORD
, "Ptr", lpBytesReturned ; DWORD* optional, out
, "WStr", lpszReason ; LPCWSTR optional
, "UInt") ; return: DWORD●ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason) = DLL("CLUSAPI.dll", "dword ClusterControlEx(int, int, dword, void*, dword, void*, dword, void*, char*)")
# 呼び出し: ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
# hCluster : HCLUSTER -> "int"
# hHostNode : HNODE optional -> "int"
# dwControlCode : DWORD -> "dword"
# lpInBuffer : void* optional -> "void*"
# nInBufferSize : DWORD -> "dword"
# lpOutBuffer : void* optional, out -> "void*"
# nOutBufferSize : DWORD -> "dword"
# lpBytesReturned : DWORD* optional, out -> "void*"
# lpszReason : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clusapi" fn ClusterControlEx(
hCluster: isize, // HCLUSTER
hHostNode: isize, // HNODE optional
dwControlCode: u32, // DWORD
lpInBuffer: ?*anyopaque, // void* optional
nInBufferSize: u32, // DWORD
lpOutBuffer: ?*anyopaque, // void* optional, out
nOutBufferSize: u32, // DWORD
lpBytesReturned: [*c]u32, // DWORD* optional, out
lpszReason: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;proc ClusterControlEx(
hCluster: int, # HCLUSTER
hHostNode: int, # HNODE optional
dwControlCode: uint32, # DWORD
lpInBuffer: pointer, # void* optional
nInBufferSize: uint32, # DWORD
lpOutBuffer: pointer, # void* optional, out
nOutBufferSize: uint32, # DWORD
lpBytesReturned: ptr uint32, # DWORD* optional, out
lpszReason: WideCString # LPCWSTR optional
): uint32 {.importc: "ClusterControlEx", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
uint ClusterControlEx(
ptrdiff_t hCluster, // HCLUSTER
ptrdiff_t hHostNode, // HNODE optional
uint dwControlCode, // DWORD
void* lpInBuffer, // void* optional
uint nInBufferSize, // DWORD
void* lpOutBuffer, // void* optional, out
uint nOutBufferSize, // DWORD
uint* lpBytesReturned, // DWORD* optional, out
const(wchar)* lpszReason // LPCWSTR optional
);ccall((:ClusterControlEx, "CLUSAPI.dll"), stdcall, UInt32,
(Int, Int, UInt32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}, Cwstring),
hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
# hCluster : HCLUSTER -> Int
# hHostNode : HNODE optional -> Int
# dwControlCode : DWORD -> UInt32
# lpInBuffer : void* optional -> Ptr{Cvoid}
# nInBufferSize : DWORD -> UInt32
# lpOutBuffer : void* optional, out -> Ptr{Cvoid}
# nOutBufferSize : DWORD -> UInt32
# lpBytesReturned : DWORD* optional, out -> Ptr{UInt32}
# lpszReason : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ClusterControlEx(
intptr_t hCluster,
intptr_t hHostNode,
uint32_t dwControlCode,
void* lpInBuffer,
uint32_t nInBufferSize,
void* lpOutBuffer,
uint32_t nOutBufferSize,
uint32_t* lpBytesReturned,
const uint16_t* lpszReason);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
-- hCluster : HCLUSTER
-- hHostNode : HNODE optional
-- dwControlCode : DWORD
-- lpInBuffer : void* optional
-- nInBufferSize : DWORD
-- lpOutBuffer : void* optional, out
-- nOutBufferSize : DWORD
-- lpBytesReturned : DWORD* optional, out
-- lpszReason : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterControlEx = lib.func('__stdcall', 'ClusterControlEx', 'uint32_t', ['intptr_t', 'intptr_t', 'uint32_t', 'void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t *', 'str16']);
// ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
// hCluster : HCLUSTER -> 'intptr_t'
// hHostNode : HNODE optional -> 'intptr_t'
// dwControlCode : DWORD -> 'uint32_t'
// lpInBuffer : void* optional -> 'void *'
// nInBufferSize : DWORD -> 'uint32_t'
// lpOutBuffer : void* optional, out -> 'void *'
// nOutBufferSize : DWORD -> 'uint32_t'
// lpBytesReturned : DWORD* optional, out -> 'uint32_t *'
// lpszReason : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterControlEx: { parameters: ["isize", "isize", "u32", "pointer", "u32", "pointer", "u32", "pointer", "buffer"], result: "u32" },
});
// lib.symbols.ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
// hCluster : HCLUSTER -> "isize"
// hHostNode : HNODE optional -> "isize"
// dwControlCode : DWORD -> "u32"
// lpInBuffer : void* optional -> "pointer"
// nInBufferSize : DWORD -> "u32"
// lpOutBuffer : void* optional, out -> "pointer"
// nOutBufferSize : DWORD -> "u32"
// lpBytesReturned : DWORD* optional, out -> "pointer"
// lpszReason : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ClusterControlEx(
intptr_t hCluster,
intptr_t hHostNode,
uint32_t dwControlCode,
void* lpInBuffer,
uint32_t nInBufferSize,
void* lpOutBuffer,
uint32_t nOutBufferSize,
uint32_t* lpBytesReturned,
const uint16_t* lpszReason);
C, "CLUSAPI.dll");
// $ffi->ClusterControlEx(hCluster, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason);
// hCluster : HCLUSTER
// hHostNode : HNODE optional
// dwControlCode : DWORD
// lpInBuffer : void* optional
// nInBufferSize : DWORD
// lpOutBuffer : void* optional, out
// nOutBufferSize : DWORD
// lpBytesReturned : DWORD* optional, out
// lpszReason : LPCWSTR optional
// 構造体/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 ClusterControlEx(
long hCluster, // HCLUSTER
long hHostNode, // HNODE optional
int dwControlCode, // DWORD
Pointer lpInBuffer, // void* optional
int nInBufferSize, // DWORD
Pointer lpOutBuffer, // void* optional, out
int nOutBufferSize, // DWORD
IntByReference lpBytesReturned, // DWORD* optional, out
WString lpszReason // LPCWSTR optional
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterControlEx = ClusterControlEx(
hCluster : LibC::SSizeT, # HCLUSTER
hHostNode : LibC::SSizeT, # HNODE optional
dwControlCode : UInt32, # DWORD
lpInBuffer : Void*, # void* optional
nInBufferSize : UInt32, # DWORD
lpOutBuffer : Void*, # void* optional, out
nOutBufferSize : UInt32, # DWORD
lpBytesReturned : UInt32*, # DWORD* optional, out
lpszReason : UInt16* # LPCWSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterControlExNative = Uint32 Function(IntPtr, IntPtr, Uint32, Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Uint32>, Pointer<Utf16>);
typedef ClusterControlExDart = int Function(int, int, int, Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>, Pointer<Utf16>);
final ClusterControlEx = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterControlExNative, ClusterControlExDart>('ClusterControlEx');
// hCluster : HCLUSTER -> IntPtr
// hHostNode : HNODE optional -> IntPtr
// dwControlCode : DWORD -> Uint32
// lpInBuffer : void* optional -> Pointer<Void>
// nInBufferSize : DWORD -> Uint32
// lpOutBuffer : void* optional, out -> Pointer<Void>
// nOutBufferSize : DWORD -> Uint32
// lpBytesReturned : DWORD* optional, out -> Pointer<Uint32>
// lpszReason : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ClusterControlEx(
hCluster: NativeInt; // HCLUSTER
hHostNode: NativeInt; // HNODE optional
dwControlCode: DWORD; // DWORD
lpInBuffer: Pointer; // void* optional
nInBufferSize: DWORD; // DWORD
lpOutBuffer: Pointer; // void* optional, out
nOutBufferSize: DWORD; // DWORD
lpBytesReturned: Pointer; // DWORD* optional, out
lpszReason: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'ClusterControlEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterControlEx"
c_ClusterControlEx :: CIntPtr -> CIntPtr -> Word32 -> Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr Word32 -> CWString -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- hHostNode : HNODE optional -> CIntPtr
-- dwControlCode : DWORD -> Word32
-- lpInBuffer : void* optional -> Ptr ()
-- nInBufferSize : DWORD -> Word32
-- lpOutBuffer : void* optional, out -> Ptr ()
-- nOutBufferSize : DWORD -> Word32
-- lpBytesReturned : DWORD* optional, out -> Ptr Word32
-- lpszReason : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clustercontrolex =
foreign "ClusterControlEx"
(intptr_t @-> intptr_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* hHostNode : HNODE optional -> intptr_t *)
(* dwControlCode : DWORD -> uint32_t *)
(* lpInBuffer : void* optional -> (ptr void) *)
(* nInBufferSize : DWORD -> uint32_t *)
(* lpOutBuffer : void* optional, out -> (ptr void) *)
(* nOutBufferSize : DWORD -> uint32_t *)
(* lpBytesReturned : DWORD* optional, out -> (ptr uint32_t) *)
(* lpszReason : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterControlEx" cluster-control-ex :convention :stdcall) :uint32
(h-cluster :int64) ; HCLUSTER
(h-host-node :int64) ; HNODE optional
(dw-control-code :uint32) ; DWORD
(lp-in-buffer :pointer) ; void* optional
(n-in-buffer-size :uint32) ; DWORD
(lp-out-buffer :pointer) ; void* optional, out
(n-out-buffer-size :uint32) ; DWORD
(lp-bytes-returned :pointer) ; DWORD* optional, out
(lpsz-reason (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterControlEx = Win32::API::More->new('CLUSAPI',
'DWORD ClusterControlEx(LPARAM hCluster, LPARAM hHostNode, DWORD dwControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPVOID lpBytesReturned, LPCWSTR lpszReason)');
# my $ret = $ClusterControlEx->Call($hCluster, $hHostNode, $dwControlCode, $lpInBuffer, $nInBufferSize, $lpOutBuffer, $nOutBufferSize, $lpBytesReturned, $lpszReason);
# hCluster : HCLUSTER -> LPARAM
# hHostNode : HNODE optional -> LPARAM
# dwControlCode : DWORD -> DWORD
# lpInBuffer : void* optional -> LPVOID
# nInBufferSize : DWORD -> DWORD
# lpOutBuffer : void* optional, out -> LPVOID
# nOutBufferSize : DWORD -> DWORD
# lpBytesReturned : DWORD* optional, out -> LPVOID
# lpszReason : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f ClusterControl — クラスターに対して制御コードを発行し操作を実行する。