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

GetClusterNetInterface

関数
ノードとネットワークからインターフェイス名を取得する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD GetClusterNetInterface(
    HCLUSTER hCluster,
    LPCWSTR lpszNodeName,
    LPCWSTR lpszNetworkName,
    LPWSTR lpszInterfaceName,
    DWORD* lpcchInterfaceName
);

パラメーター

名前方向説明
hClusterHCLUSTERin対象クラスターのハンドル。
lpszNodeNameLPCWSTRinインターフェイスが属するノード名のワイド文字列。
lpszNetworkNameLPCWSTRinインターフェイスが属するネットワーク名のワイド文字列。
lpszInterfaceNameLPWSTRout見つかったインターフェイス名を受け取るバッファ。
lpcchInterfaceNameDWORD*inout入出力。バッファ文字数を渡し、必要文字数を受け取るDWORDポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetClusterNetInterface(
    HCLUSTER hCluster,
    LPCWSTR lpszNodeName,
    LPCWSTR lpszNetworkName,
    LPWSTR lpszInterfaceName,
    DWORD* lpcchInterfaceName
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint GetClusterNetInterface(
    IntPtr hCluster,   // HCLUSTER
    [MarshalAs(UnmanagedType.LPWStr)] string lpszNodeName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszNetworkName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszInterfaceName,   // LPWSTR out
    ref uint lpcchInterfaceName   // DWORD* in/out
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function GetClusterNetInterface(
    hCluster As IntPtr,   ' HCLUSTER
    <MarshalAs(UnmanagedType.LPWStr)> lpszNodeName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszNetworkName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszInterfaceName As System.Text.StringBuilder,   ' LPWSTR out
    ByRef lpcchInterfaceName As UInteger   ' DWORD* in/out
) As UInteger
End Function
' hCluster : HCLUSTER
' lpszNodeName : LPCWSTR
' lpszNetworkName : LPCWSTR
' lpszInterfaceName : LPWSTR out
' lpcchInterfaceName : DWORD* in/out
Declare PtrSafe Function GetClusterNetInterface Lib "clusapi" ( _
    ByVal hCluster As LongPtr, _
    ByVal lpszNodeName As LongPtr, _
    ByVal lpszNetworkName As LongPtr, _
    ByVal lpszInterfaceName As LongPtr, _
    ByRef lpcchInterfaceName As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetClusterNetInterface = ctypes.windll.clusapi.GetClusterNetInterface
GetClusterNetInterface.restype = wintypes.DWORD
GetClusterNetInterface.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # lpszNodeName : LPCWSTR
    wintypes.LPCWSTR,  # lpszNetworkName : LPCWSTR
    wintypes.LPWSTR,  # lpszInterfaceName : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # lpcchInterfaceName : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procGetClusterNetInterface = clusapi.NewProc("GetClusterNetInterface")
)

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

extern "clusapi" fn GetClusterNetInterface(
    hCluster: isize, // HCLUSTER
    lpszNodeName: [*c]const u16, // LPCWSTR
    lpszNetworkName: [*c]const u16, // LPCWSTR
    lpszInterfaceName: [*c]u16, // LPWSTR out
    lpcchInterfaceName: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;
proc GetClusterNetInterface(
    hCluster: int,  # HCLUSTER
    lpszNodeName: WideCString,  # LPCWSTR
    lpszNetworkName: WideCString,  # LPCWSTR
    lpszInterfaceName: ptr uint16,  # LPWSTR out
    lpcchInterfaceName: ptr uint32  # DWORD* in/out
): uint32 {.importc: "GetClusterNetInterface", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
uint GetClusterNetInterface(
    ptrdiff_t hCluster,   // HCLUSTER
    const(wchar)* lpszNodeName,   // LPCWSTR
    const(wchar)* lpszNetworkName,   // LPCWSTR
    wchar* lpszInterfaceName,   // LPWSTR out
    uint* lpcchInterfaceName   // DWORD* in/out
);
ccall((:GetClusterNetInterface, "CLUSAPI.dll"), stdcall, UInt32,
      (Int, Cwstring, Cwstring, Ptr{UInt16}, Ptr{UInt32}),
      hCluster, lpszNodeName, lpszNetworkName, lpszInterfaceName, lpcchInterfaceName)
# hCluster : HCLUSTER -> Int
# lpszNodeName : LPCWSTR -> Cwstring
# lpszNetworkName : LPCWSTR -> Cwstring
# lpszInterfaceName : LPWSTR out -> Ptr{UInt16}
# lpcchInterfaceName : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t GetClusterNetInterface(
    intptr_t hCluster,
    const uint16_t* lpszNodeName,
    const uint16_t* lpszNetworkName,
    uint16_t* lpszInterfaceName,
    uint32_t* lpcchInterfaceName);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.GetClusterNetInterface(hCluster, lpszNodeName, lpszNetworkName, lpszInterfaceName, lpcchInterfaceName)
-- hCluster : HCLUSTER
-- lpszNodeName : LPCWSTR
-- lpszNetworkName : LPCWSTR
-- lpszInterfaceName : LPWSTR out
-- lpcchInterfaceName : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const GetClusterNetInterface = lib.func('__stdcall', 'GetClusterNetInterface', 'uint32_t', ['intptr_t', 'str16', 'str16', 'uint16_t *', 'uint32_t *']);
// GetClusterNetInterface(hCluster, lpszNodeName, lpszNetworkName, lpszInterfaceName, lpcchInterfaceName)
// hCluster : HCLUSTER -> 'intptr_t'
// lpszNodeName : LPCWSTR -> 'str16'
// lpszNetworkName : LPCWSTR -> 'str16'
// lpszInterfaceName : LPWSTR out -> 'uint16_t *'
// lpcchInterfaceName : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  GetClusterNetInterface: { parameters: ["isize", "buffer", "buffer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.GetClusterNetInterface(hCluster, lpszNodeName, lpszNetworkName, lpszInterfaceName, lpcchInterfaceName)
// hCluster : HCLUSTER -> "isize"
// lpszNodeName : LPCWSTR -> "buffer"
// lpszNetworkName : LPCWSTR -> "buffer"
// lpszInterfaceName : LPWSTR out -> "buffer"
// lpcchInterfaceName : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t GetClusterNetInterface(
    intptr_t hCluster,
    const uint16_t* lpszNodeName,
    const uint16_t* lpszNetworkName,
    uint16_t* lpszInterfaceName,
    uint32_t* lpcchInterfaceName);
C, "CLUSAPI.dll");
// $ffi->GetClusterNetInterface(hCluster, lpszNodeName, lpszNetworkName, lpszInterfaceName, lpcchInterfaceName);
// hCluster : HCLUSTER
// lpszNodeName : LPCWSTR
// lpszNetworkName : LPCWSTR
// lpszInterfaceName : LPWSTR out
// lpcchInterfaceName : DWORD* in/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 GetClusterNetInterface(
        long hCluster,   // HCLUSTER
        WString lpszNodeName,   // LPCWSTR
        WString lpszNetworkName,   // LPCWSTR
        char[] lpszInterfaceName,   // LPWSTR out
        IntByReference lpcchInterfaceName   // DWORD* in/out
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun GetClusterNetInterface = GetClusterNetInterface(
    hCluster : LibC::SSizeT,   # HCLUSTER
    lpszNodeName : UInt16*,   # LPCWSTR
    lpszNetworkName : UInt16*,   # LPCWSTR
    lpszInterfaceName : UInt16*,   # LPWSTR out
    lpcchInterfaceName : UInt32*   # DWORD* in/out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetClusterNetInterfaceNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef GetClusterNetInterfaceDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final GetClusterNetInterface = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<GetClusterNetInterfaceNative, GetClusterNetInterfaceDart>('GetClusterNetInterface');
// hCluster : HCLUSTER -> IntPtr
// lpszNodeName : LPCWSTR -> Pointer<Utf16>
// lpszNetworkName : LPCWSTR -> Pointer<Utf16>
// lpszInterfaceName : LPWSTR out -> Pointer<Utf16>
// lpcchInterfaceName : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetClusterNetInterface(
  hCluster: NativeInt;   // HCLUSTER
  lpszNodeName: PWideChar;   // LPCWSTR
  lpszNetworkName: PWideChar;   // LPCWSTR
  lpszInterfaceName: PWideChar;   // LPWSTR out
  lpcchInterfaceName: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'GetClusterNetInterface';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetClusterNetInterface"
  c_GetClusterNetInterface :: CIntPtr -> CWString -> CWString -> CWString -> Ptr Word32 -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- lpszNodeName : LPCWSTR -> CWString
-- lpszNetworkName : LPCWSTR -> CWString
-- lpszInterfaceName : LPWSTR out -> CWString
-- lpcchInterfaceName : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getclusternetinterface =
  foreign "GetClusterNetInterface"
    (intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* lpszNodeName : LPCWSTR -> (ptr uint16_t) *)
(* lpszNetworkName : LPCWSTR -> (ptr uint16_t) *)
(* lpszInterfaceName : LPWSTR out -> (ptr uint16_t) *)
(* lpcchInterfaceName : DWORD* in/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 ("GetClusterNetInterface" get-cluster-net-interface :convention :stdcall) :uint32
  (h-cluster :int64)   ; HCLUSTER
  (lpsz-node-name (:string :encoding :utf-16le))   ; LPCWSTR
  (lpsz-network-name (:string :encoding :utf-16le))   ; LPCWSTR
  (lpsz-interface-name :pointer)   ; LPWSTR out
  (lpcch-interface-name :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetClusterNetInterface = Win32::API::More->new('CLUSAPI',
    'DWORD GetClusterNetInterface(LPARAM hCluster, LPCWSTR lpszNodeName, LPCWSTR lpszNetworkName, LPWSTR lpszInterfaceName, LPVOID lpcchInterfaceName)');
# my $ret = $GetClusterNetInterface->Call($hCluster, $lpszNodeName, $lpszNetworkName, $lpszInterfaceName, $lpcchInterfaceName);
# hCluster : HCLUSTER -> LPARAM
# lpszNodeName : LPCWSTR -> LPCWSTR
# lpszNetworkName : LPCWSTR -> LPCWSTR
# lpszInterfaceName : LPWSTR out -> LPWSTR
# lpcchInterfaceName : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。