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

OpenClusterNetInterface

関数
指定名のクラスターネットワークインターフェイスを開く。
DLLCLUSAPI.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2008

シグネチャ

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

HNETINTERFACE OpenClusterNetInterface(
    HCLUSTER hCluster,
    LPCWSTR lpszInterfaceName
);

パラメーター

名前方向
hClusterHCLUSTERin
lpszInterfaceNameLPCWSTRin

戻り値の型: HNETINTERFACE

各言語での呼び出し定義

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

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

OpenClusterNetInterface = ctypes.windll.clusapi.OpenClusterNetInterface
OpenClusterNetInterface.restype = ctypes.c_ssize_t
OpenClusterNetInterface.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # lpszInterfaceName : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procOpenClusterNetInterface = clusapi.NewProc("OpenClusterNetInterface")
)

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