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

OpenClusterNetInterface

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

シグネチャ

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

HNETINTERFACE OpenClusterNetInterface(
    HCLUSTER hCluster,
    LPCWSTR lpszInterfaceName
);

パラメーター

名前方向説明
hClusterHCLUSTERin対象クラスターのハンドル。OpenClusterで取得する。
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)。
const std = @import("std");

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

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

foreign import stdcall safe "OpenClusterNetInterface"
  c_OpenClusterNetInterface :: CIntPtr -> CWString -> IO CIntPtr
-- hCluster : HCLUSTER -> CIntPtr
-- lpszInterfaceName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

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

関連項目

類似 API