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

CreateClusterGroupSet

関数
新しいクラスターグループセットを作成する。
DLLCLUSAPI.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2016

シグネチャ

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

HGROUPSET CreateClusterGroupSet(
    HCLUSTER hCluster,
    LPCWSTR groupSetName
);

パラメーター

名前方向
hClusterHCLUSTERin
groupSetNameLPCWSTRin

戻り値の型: HGROUPSET

各言語での呼び出し定義

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

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

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

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procCreateClusterGroupSet = clusapi.NewProc("CreateClusterGroupSet")
)

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