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

ClusterNetInterfaceControlEx

関数
理由付きでネットワークインターフェイスに制御コードを発行する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ClusterNetInterfaceControlEx(
    HNETINTERFACE hNetInterface,
    HNODE hHostNode,   // optional
    DWORD dwControlCode,
    void* lpInBuffer,   // optional
    DWORD nInBufferSize,
    void* lpOutBuffer,   // optional
    DWORD nOutBufferSize,
    DWORD* lpBytesReturned,   // optional
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hNetInterfaceHNETINTERFACEin
hHostNodeHNODEinoptional
dwControlCodeDWORDin
lpInBuffervoid*inoptional
nInBufferSizeDWORDin
lpOutBuffervoid*outoptional
nOutBufferSizeDWORDin
lpBytesReturnedDWORD*outoptional
lpszReasonLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ClusterNetInterfaceControlEx(
    HNETINTERFACE hNetInterface,
    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 ClusterNetInterfaceControlEx(
    IntPtr hNetInterface,   // HNETINTERFACE
    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 ClusterNetInterfaceControlEx(
    hNetInterface As IntPtr,   ' HNETINTERFACE
    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
' hNetInterface : HNETINTERFACE
' 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 ClusterNetInterfaceControlEx Lib "clusapi" ( _
    ByVal hNetInterface 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

ClusterNetInterfaceControlEx = ctypes.windll.clusapi.ClusterNetInterfaceControlEx
ClusterNetInterfaceControlEx.restype = wintypes.DWORD
ClusterNetInterfaceControlEx.argtypes = [
    ctypes.c_ssize_t,  # hNetInterface : HNETINTERFACE
    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')
ClusterNetInterfaceControlEx = Fiddle::Function.new(
  lib['ClusterNetInterfaceControlEx'],
  [
    Fiddle::TYPE_INTPTR_T,  # hNetInterface : HNETINTERFACE
    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 ClusterNetInterfaceControlEx(
        hNetInterface: isize,  // HNETINTERFACE
        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 ClusterNetInterfaceControlEx(IntPtr hNetInterface, 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_ClusterNetInterfaceControlEx' -Namespace Win32 -PassThru
# $api::ClusterNetInterfaceControlEx(hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
#uselib "CLUSAPI.dll"
#func global ClusterNetInterfaceControlEx "ClusterNetInterfaceControlEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ClusterNetInterfaceControlEx hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, varptr(lpBytesReturned), lpszReason   ; 戻り値は stat
; hNetInterface : HNETINTERFACE -> "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 ClusterNetInterfaceControlEx "ClusterNetInterfaceControlEx" sptr, sptr, int, sptr, int, sptr, int, var, wstr
; res = ClusterNetInterfaceControlEx(hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
; hNetInterface : HNETINTERFACE -> "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 方式にも切替可。
出力引数:
; DWORD ClusterNetInterfaceControlEx(HNETINTERFACE hNetInterface, HNODE hHostNode, DWORD dwControlCode, void* lpInBuffer, DWORD nInBufferSize, void* lpOutBuffer, DWORD nOutBufferSize, DWORD* lpBytesReturned, LPCWSTR lpszReason)
#uselib "CLUSAPI.dll"
#cfunc global ClusterNetInterfaceControlEx "ClusterNetInterfaceControlEx" intptr, intptr, int, intptr, int, intptr, int, var, wstr
; res = ClusterNetInterfaceControlEx(hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
; hNetInterface : HNETINTERFACE -> "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 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterNetInterfaceControlEx = clusapi.NewProc("ClusterNetInterfaceControlEx")
)

// hNetInterface (HNETINTERFACE), 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 := procClusterNetInterfaceControlEx.Call(
	uintptr(hNetInterface),
	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   // DWORD
function ClusterNetInterfaceControlEx(
  hNetInterface: NativeInt;   // HNETINTERFACE
  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 'ClusterNetInterfaceControlEx';
result := DllCall("CLUSAPI\ClusterNetInterfaceControlEx"
    , "Ptr", hNetInterface   ; HNETINTERFACE
    , "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
●ClusterNetInterfaceControlEx(hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason) = DLL("CLUSAPI.dll", "dword ClusterNetInterfaceControlEx(int, int, dword, void*, dword, void*, dword, void*, char*)")
# 呼び出し: ClusterNetInterfaceControlEx(hNetInterface, hHostNode, dwControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpszReason)
# hNetInterface : HNETINTERFACE -> "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)。