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)。
const std = @import("std");

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

typedef GetClusterInformationNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
typedef GetClusterInformationDart = int Function(int, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
final GetClusterInformation = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<GetClusterInformationNative, GetClusterInformationDart>('GetClusterInformation');
// hCluster : HCLUSTER -> IntPtr
// lpszClusterName : LPWSTR out -> Pointer<Utf16>
// lpcchClusterName : DWORD* in/out -> Pointer<Uint32>
// lpClusterInfo : CLUSTERVERSIONINFO* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetClusterInformation"
  c_GetClusterInformation :: CIntPtr -> CWString -> Ptr Word32 -> Ptr () -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- lpszClusterName : LPWSTR out -> CWString
-- lpcchClusterName : DWORD* in/out -> Ptr Word32
-- lpClusterInfo : CLUSTERVERSIONINFO* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getclusterinformation =
  foreign "GetClusterInformation"
    (intptr_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* lpszClusterName : LPWSTR out -> (ptr uint16_t) *)
(* lpcchClusterName : DWORD* in/out -> (ptr uint32_t) *)
(* lpClusterInfo : CLUSTERVERSIONINFO* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("GetClusterInformation" get-cluster-information :convention :stdcall) :uint32
  (h-cluster :int64)   ; HCLUSTER
  (lpsz-cluster-name :pointer)   ; LPWSTR out
  (lpcch-cluster-name :pointer)   ; DWORD* in/out
  (lp-cluster-info :pointer))   ; CLUSTERVERSIONINFO* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetClusterInformation = Win32::API::More->new('CLUSAPI',
    'DWORD GetClusterInformation(LPARAM hCluster, LPWSTR lpszClusterName, LPVOID lpcchClusterName, LPVOID lpClusterInfo)');
# my $ret = $GetClusterInformation->Call($hCluster, $lpszClusterName, $lpcchClusterName, $lpClusterInfo);
# hCluster : HCLUSTER -> LPARAM
# lpszClusterName : LPWSTR out -> LPWSTR
# lpcchClusterName : DWORD* in/out -> LPVOID
# lpClusterInfo : CLUSTERVERSIONINFO* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型