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

SetClusterGroupNameEx

関数
理由付きでクラスターグループの名前を設定する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD SetClusterGroupNameEx(
    HGROUP hGroup,
    LPCWSTR lpszGroupName,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hGroupHGROUPin
lpszGroupNameLPCWSTRin
lpszReasonLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

SetClusterGroupNameEx = ctypes.windll.clusapi.SetClusterGroupNameEx
SetClusterGroupNameEx.restype = wintypes.DWORD
SetClusterGroupNameEx.argtypes = [
    ctypes.c_ssize_t,  # hGroup : HGROUP
    wintypes.LPCWSTR,  # lpszGroupName : LPCWSTR
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procSetClusterGroupNameEx = clusapi.NewProc("SetClusterGroupNameEx")
)

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