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

GetClusterInformation

関数
クラスター名とバージョン情報を取得する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD GetClusterInformation(
    HCLUSTER hCluster,
    LPWSTR lpszClusterName,
    DWORD* lpcchClusterName,
    CLUSTERVERSIONINFO* lpClusterInfo   // optional
);

パラメーター

名前方向
hClusterHCLUSTERin
lpszClusterNameLPWSTRout
lpcchClusterNameDWORD*inout
lpClusterInfoCLUSTERVERSIONINFO*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

GetClusterInformation = ctypes.windll.clusapi.GetClusterInformation
GetClusterInformation.restype = wintypes.DWORD
GetClusterInformation.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPWSTR,  # lpszClusterName : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # lpcchClusterName : DWORD* in/out
    ctypes.c_void_p,  # lpClusterInfo : CLUSTERVERSIONINFO* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procGetClusterInformation = clusapi.NewProc("GetClusterInformation")
)

// hCluster (HCLUSTER), lpszClusterName (LPWSTR out), lpcchClusterName (DWORD* in/out), lpClusterInfo (CLUSTERVERSIONINFO* optional, out)
r1, _, err := procGetClusterInformation.Call(
	uintptr(hCluster),
	uintptr(lpszClusterName),
	uintptr(lpcchClusterName),
	uintptr(lpClusterInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetClusterInformation(
  hCluster: NativeInt;   // HCLUSTER
  lpszClusterName: PWideChar;   // LPWSTR out
  lpcchClusterName: Pointer;   // DWORD* in/out
  lpClusterInfo: Pointer   // CLUSTERVERSIONINFO* optional, out
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'GetClusterInformation';
result := DllCall("CLUSAPI\GetClusterInformation"
    , "Ptr", hCluster   ; HCLUSTER
    , "Ptr", lpszClusterName   ; LPWSTR out
    , "Ptr", lpcchClusterName   ; DWORD* in/out
    , "Ptr", lpClusterInfo   ; CLUSTERVERSIONINFO* optional, out
    , "UInt")   ; return: DWORD
●GetClusterInformation(hCluster, lpszClusterName, lpcchClusterName, lpClusterInfo) = DLL("CLUSAPI.dll", "dword GetClusterInformation(int, char*, void*, void*)")
# 呼び出し: GetClusterInformation(hCluster, lpszClusterName, lpcchClusterName, lpClusterInfo)
# hCluster : HCLUSTER -> "int"
# lpszClusterName : LPWSTR out -> "char*"
# lpcchClusterName : DWORD* in/out -> "void*"
# lpClusterInfo : CLUSTERVERSIONINFO* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。