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

GetClusterNetInterfaceState

関数
クラスターネットワークインターフェイスの状態を取得する。
DLLCLUSAPI.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2008

シグネチャ

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

CLUSTER_NETINTERFACE_STATE GetClusterNetInterfaceState(
    HNETINTERFACE hNetInterface
);

パラメーター

名前方向説明
hNetInterfaceHNETINTERFACEin状態を取得する対象のネットワークインターフェイスハンドル。

戻り値の型: CLUSTER_NETINTERFACE_STATE

各言語での呼び出し定義

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

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

GetClusterNetInterfaceState = ctypes.windll.clusapi.GetClusterNetInterfaceState
GetClusterNetInterfaceState.restype = ctypes.c_int
GetClusterNetInterfaceState.argtypes = [
    ctypes.c_ssize_t,  # hNetInterface : HNETINTERFACE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procGetClusterNetInterfaceState = clusapi.NewProc("GetClusterNetInterfaceState")
)

// hNetInterface (HNETINTERFACE)
r1, _, err := procGetClusterNetInterfaceState.Call(
	uintptr(hNetInterface),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CLUSTER_NETINTERFACE_STATE
function GetClusterNetInterfaceState(
  hNetInterface: NativeInt   // HNETINTERFACE
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'GetClusterNetInterfaceState';
result := DllCall("CLUSAPI\GetClusterNetInterfaceState"
    , "Ptr", hNetInterface   ; HNETINTERFACE
    , "Int")   ; return: CLUSTER_NETINTERFACE_STATE
●GetClusterNetInterfaceState(hNetInterface) = DLL("CLUSAPI.dll", "int GetClusterNetInterfaceState(int)")
# 呼び出し: GetClusterNetInterfaceState(hNetInterface)
# hNetInterface : HNETINTERFACE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef GetClusterNetInterfaceStateNative = Int32 Function(IntPtr);
typedef GetClusterNetInterfaceStateDart = int Function(int);
final GetClusterNetInterfaceState = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<GetClusterNetInterfaceStateNative, GetClusterNetInterfaceStateDart>('GetClusterNetInterfaceState');
// hNetInterface : HNETINTERFACE -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetClusterNetInterfaceState(
  hNetInterface: NativeInt   // HNETINTERFACE
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'GetClusterNetInterfaceState';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetClusterNetInterfaceState"
  c_GetClusterNetInterfaceState :: CIntPtr -> IO Int32
-- hNetInterface : HNETINTERFACE -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getclusternetinterfacestate =
  foreign "GetClusterNetInterfaceState"
    (intptr_t @-> returning int32_t)
(* hNetInterface : HNETINTERFACE -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("GetClusterNetInterfaceState" get-cluster-net-interface-state :convention :stdcall) :int32
  (h-net-interface :int64))   ; HNETINTERFACE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetClusterNetInterfaceState = Win32::API::More->new('CLUSAPI',
    'int GetClusterNetInterfaceState(LPARAM hNetInterface)');
# my $ret = $GetClusterNetInterfaceState->Call($hNetInterface);
# hNetInterface : HNETINTERFACE -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型