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

OpenClusterGroup

関数
指定名のクラスターグループを開いてハンドルを取得する。
DLLCLUSAPI.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2008

シグネチャ

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

HGROUP OpenClusterGroup(
    HCLUSTER hCluster,
    LPCWSTR lpszGroupName
);

パラメーター

名前方向
hClusterHCLUSTERin
lpszGroupNameLPCWSTRin

戻り値の型: HGROUP

各言語での呼び出し定義

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

HGROUP OpenClusterGroup(
    HCLUSTER hCluster,
    LPCWSTR lpszGroupName
);
[DllImport("CLUSAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr OpenClusterGroup(
    IntPtr hCluster,   // HCLUSTER
    [MarshalAs(UnmanagedType.LPWStr)] string lpszGroupName   // LPCWSTR
);
<DllImport("CLUSAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function OpenClusterGroup(
    hCluster As IntPtr,   ' HCLUSTER
    <MarshalAs(UnmanagedType.LPWStr)> lpszGroupName As String   ' LPCWSTR
) As IntPtr
End Function
' hCluster : HCLUSTER
' lpszGroupName : LPCWSTR
Declare PtrSafe Function OpenClusterGroup Lib "clusapi" ( _
    ByVal hCluster As LongPtr, _
    ByVal lpszGroupName As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OpenClusterGroup = ctypes.windll.clusapi.OpenClusterGroup
OpenClusterGroup.restype = ctypes.c_ssize_t
OpenClusterGroup.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # lpszGroupName : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procOpenClusterGroup = clusapi.NewProc("OpenClusterGroup")
)

// hCluster (HCLUSTER), lpszGroupName (LPCWSTR)
r1, _, err := procOpenClusterGroup.Call(
	uintptr(hCluster),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszGroupName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HGROUP
function OpenClusterGroup(
  hCluster: NativeInt;   // HCLUSTER
  lpszGroupName: PWideChar   // LPCWSTR
): NativeInt; stdcall;
  external 'CLUSAPI.dll' name 'OpenClusterGroup';
result := DllCall("CLUSAPI\OpenClusterGroup"
    , "Ptr", hCluster   ; HCLUSTER
    , "WStr", lpszGroupName   ; LPCWSTR
    , "Ptr")   ; return: HGROUP
●OpenClusterGroup(hCluster, lpszGroupName) = DLL("CLUSAPI.dll", "int OpenClusterGroup(int, char*)")
# 呼び出し: OpenClusterGroup(hCluster, lpszGroupName)
# hCluster : HCLUSTER -> "int"
# lpszGroupName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。