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

SetClusterName

関数
クラスターの名前を変更する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD SetClusterName(
    HCLUSTER hCluster,
    LPCWSTR lpszNewClusterName
);

パラメーター

名前方向
hClusterHCLUSTERin
lpszNewClusterNameLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

SetClusterName = ctypes.windll.clusapi.SetClusterName
SetClusterName.restype = wintypes.DWORD
SetClusterName.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # lpszNewClusterName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procSetClusterName = clusapi.NewProc("SetClusterName")
)

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