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

ResUtilGetClusterRoleState

関数
指定クラスタロールの有効状態を取得する。
DLLRESUTILS.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2008

シグネチャ

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

CLUSTER_ROLE_STATE ResUtilGetClusterRoleState(
    HCLUSTER hCluster,
    CLUSTER_ROLE eClusterRole
);

パラメーター

名前方向説明
hClusterHCLUSTERin状態を問い合わせる対象クラスターのハンドル。
eClusterRoleCLUSTER_ROLEin状態を取得するクラスターロールを指定する列挙値(CLUSTER_ROLE)。

戻り値の型: CLUSTER_ROLE_STATE

各言語での呼び出し定義

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

CLUSTER_ROLE_STATE ResUtilGetClusterRoleState(
    HCLUSTER hCluster,
    CLUSTER_ROLE eClusterRole
);
[DllImport("RESUTILS.dll", SetLastError = true, ExactSpelling = true)]
static extern int ResUtilGetClusterRoleState(
    IntPtr hCluster,   // HCLUSTER
    int eClusterRole   // CLUSTER_ROLE
);
<DllImport("RESUTILS.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ResUtilGetClusterRoleState(
    hCluster As IntPtr,   ' HCLUSTER
    eClusterRole As Integer   ' CLUSTER_ROLE
) As Integer
End Function
' hCluster : HCLUSTER
' eClusterRole : CLUSTER_ROLE
Declare PtrSafe Function ResUtilGetClusterRoleState Lib "resutils" ( _
    ByVal hCluster As LongPtr, _
    ByVal eClusterRole As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilGetClusterRoleState = ctypes.windll.resutils.ResUtilGetClusterRoleState
ResUtilGetClusterRoleState.restype = ctypes.c_int
ResUtilGetClusterRoleState.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    ctypes.c_int,  # eClusterRole : CLUSTER_ROLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilGetClusterRoleState = resutils.NewProc("ResUtilGetClusterRoleState")
)

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

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

typedef ResUtilGetClusterRoleStateNative = Int32 Function(IntPtr, Int32);
typedef ResUtilGetClusterRoleStateDart = int Function(int, int);
final ResUtilGetClusterRoleState = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilGetClusterRoleStateNative, ResUtilGetClusterRoleStateDart>('ResUtilGetClusterRoleState');
// hCluster : HCLUSTER -> IntPtr
// eClusterRole : CLUSTER_ROLE -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilGetClusterRoleState(
  hCluster: NativeInt;   // HCLUSTER
  eClusterRole: Integer   // CLUSTER_ROLE
): Integer; stdcall;
  external 'RESUTILS.dll' name 'ResUtilGetClusterRoleState';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let resutilgetclusterrolestate =
  foreign "ResUtilGetClusterRoleState"
    (intptr_t @-> int32_t @-> returning int32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* eClusterRole : CLUSTER_ROLE -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilGetClusterRoleState" res-util-get-cluster-role-state :convention :stdcall) :int32
  (h-cluster :int64)   ; HCLUSTER
  (e-cluster-role :int32))   ; CLUSTER_ROLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilGetClusterRoleState = Win32::API::More->new('RESUTILS',
    'int ResUtilGetClusterRoleState(LPARAM hCluster, int eClusterRole)');
# my $ret = $ResUtilGetClusterRoleState->Call($hCluster, $eClusterRole);
# hCluster : HCLUSTER -> LPARAM
# eClusterRole : CLUSTER_ROLE -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型