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

ClusterNodeReplacement

関数
クラスターの既存ノードを新しいノードに置き換える。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ClusterNodeReplacement(
    HCLUSTER hCluster,
    LPCWSTR lpszNodeNameCurrent,
    LPCWSTR lpszNodeNameNew
);

パラメーター

名前方向
hClusterHCLUSTERin
lpszNodeNameCurrentLPCWSTRin
lpszNodeNameNewLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterNodeReplacement = clusapi.NewProc("ClusterNodeReplacement")
)

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