ホーム › Networking.Clustering › ClusterNodeReplacement
ClusterNodeReplacement
関数クラスターの既存ノードを新しいノードに置き換える。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
DWORD ClusterNodeReplacement(
HCLUSTER hCluster,
LPCWSTR lpszNodeNameCurrent,
LPCWSTR lpszNodeNameNew
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hCluster | HCLUSTER | in | 対象クラスタへのハンドル。 |
| lpszNodeNameCurrent | LPCWSTR | in | 置き換えられる既存ノード名を指すワイド文字列。 |
| lpszNodeNameNew | LPCWSTR | in | 新たに置き換える先のノード名を指すワイド文字列。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "clusapi" fn ClusterNodeReplacement(
hCluster: isize, // HCLUSTER
lpszNodeNameCurrent: [*c]const u16, // LPCWSTR
lpszNodeNameNew: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;proc ClusterNodeReplacement(
hCluster: int, # HCLUSTER
lpszNodeNameCurrent: WideCString, # LPCWSTR
lpszNodeNameNew: WideCString # LPCWSTR
): uint32 {.importc: "ClusterNodeReplacement", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
uint ClusterNodeReplacement(
ptrdiff_t hCluster, // HCLUSTER
const(wchar)* lpszNodeNameCurrent, // LPCWSTR
const(wchar)* lpszNodeNameNew // LPCWSTR
);ccall((:ClusterNodeReplacement, "CLUSAPI.dll"), stdcall, UInt32,
(Int, Cwstring, Cwstring),
hCluster, lpszNodeNameCurrent, lpszNodeNameNew)
# hCluster : HCLUSTER -> Int
# lpszNodeNameCurrent : LPCWSTR -> Cwstring
# lpszNodeNameNew : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ClusterNodeReplacement(
intptr_t hCluster,
const uint16_t* lpszNodeNameCurrent,
const uint16_t* lpszNodeNameNew);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterNodeReplacement(hCluster, lpszNodeNameCurrent, lpszNodeNameNew)
-- hCluster : HCLUSTER
-- lpszNodeNameCurrent : LPCWSTR
-- lpszNodeNameNew : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterNodeReplacement = lib.func('__stdcall', 'ClusterNodeReplacement', 'uint32_t', ['intptr_t', 'str16', 'str16']);
// ClusterNodeReplacement(hCluster, lpszNodeNameCurrent, lpszNodeNameNew)
// hCluster : HCLUSTER -> 'intptr_t'
// lpszNodeNameCurrent : LPCWSTR -> 'str16'
// lpszNodeNameNew : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterNodeReplacement: { parameters: ["isize", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.ClusterNodeReplacement(hCluster, lpszNodeNameCurrent, lpszNodeNameNew)
// hCluster : HCLUSTER -> "isize"
// lpszNodeNameCurrent : LPCWSTR -> "buffer"
// lpszNodeNameNew : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ClusterNodeReplacement(
intptr_t hCluster,
const uint16_t* lpszNodeNameCurrent,
const uint16_t* lpszNodeNameNew);
C, "CLUSAPI.dll");
// $ffi->ClusterNodeReplacement(hCluster, lpszNodeNameCurrent, lpszNodeNameNew);
// hCluster : HCLUSTER
// lpszNodeNameCurrent : LPCWSTR
// lpszNodeNameNew : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Clusapi extends StdCallLibrary {
Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
int ClusterNodeReplacement(
long hCluster, // HCLUSTER
WString lpszNodeNameCurrent, // LPCWSTR
WString lpszNodeNameNew // LPCWSTR
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterNodeReplacement = ClusterNodeReplacement(
hCluster : LibC::SSizeT, # HCLUSTER
lpszNodeNameCurrent : UInt16*, # LPCWSTR
lpszNodeNameNew : UInt16* # LPCWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterNodeReplacementNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>);
typedef ClusterNodeReplacementDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>);
final ClusterNodeReplacement = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterNodeReplacementNative, ClusterNodeReplacementDart>('ClusterNodeReplacement');
// hCluster : HCLUSTER -> IntPtr
// lpszNodeNameCurrent : LPCWSTR -> Pointer<Utf16>
// lpszNodeNameNew : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ClusterNodeReplacement(
hCluster: NativeInt; // HCLUSTER
lpszNodeNameCurrent: PWideChar; // LPCWSTR
lpszNodeNameNew: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'ClusterNodeReplacement';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterNodeReplacement"
c_ClusterNodeReplacement :: CIntPtr -> CWString -> CWString -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- lpszNodeNameCurrent : LPCWSTR -> CWString
-- lpszNodeNameNew : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusternodereplacement =
foreign "ClusterNodeReplacement"
(intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* lpszNodeNameCurrent : LPCWSTR -> (ptr uint16_t) *)
(* lpszNodeNameNew : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterNodeReplacement" cluster-node-replacement :convention :stdcall) :uint32
(h-cluster :int64) ; HCLUSTER
(lpsz-node-name-current (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-node-name-new (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterNodeReplacement = Win32::API::More->new('CLUSAPI',
'DWORD ClusterNodeReplacement(LPARAM hCluster, LPCWSTR lpszNodeNameCurrent, LPCWSTR lpszNodeNameNew)');
# my $ret = $ClusterNodeReplacement->Call($hCluster, $lpszNodeNameCurrent, $lpszNodeNameNew);
# hCluster : HCLUSTER -> LPARAM
# lpszNodeNameCurrent : LPCWSTR -> LPCWSTR
# lpszNodeNameNew : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。