ホーム › Networking.Clustering › SetClusterNameEx
SetClusterNameEx
関数理由を付与してクラスターの名前を変更する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
DWORD SetClusterNameEx(
HCLUSTER hCluster,
LPCWSTR lpszNewClusterName,
LPCWSTR lpszReason // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hCluster | HCLUSTER | in | 対象クラスタへのハンドル。 |
| lpszNewClusterName | LPCWSTR | in | クラスタに設定する新しい名前を指すワイド文字列。 |
| lpszReason | LPCWSTR | inoptional | 操作理由を記録するためのワイド文字列。監査用で不要ならNULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
DWORD SetClusterNameEx(
HCLUSTER hCluster,
LPCWSTR lpszNewClusterName,
LPCWSTR lpszReason // optional
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint SetClusterNameEx(
IntPtr hCluster, // HCLUSTER
[MarshalAs(UnmanagedType.LPWStr)] string lpszNewClusterName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszReason // LPCWSTR optional
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function SetClusterNameEx(
hCluster As IntPtr, ' HCLUSTER
<MarshalAs(UnmanagedType.LPWStr)> lpszNewClusterName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszReason As String ' LPCWSTR optional
) As UInteger
End Function' hCluster : HCLUSTER
' lpszNewClusterName : LPCWSTR
' lpszReason : LPCWSTR optional
Declare PtrSafe Function SetClusterNameEx Lib "clusapi" ( _
ByVal hCluster As LongPtr, _
ByVal lpszNewClusterName 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
SetClusterNameEx = ctypes.windll.clusapi.SetClusterNameEx
SetClusterNameEx.restype = wintypes.DWORD
SetClusterNameEx.argtypes = [
ctypes.c_ssize_t, # hCluster : HCLUSTER
wintypes.LPCWSTR, # lpszNewClusterName : LPCWSTR
wintypes.LPCWSTR, # lpszReason : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
SetClusterNameEx = Fiddle::Function.new(
lib['SetClusterNameEx'],
[
Fiddle::TYPE_INTPTR_T, # hCluster : HCLUSTER
Fiddle::TYPE_VOIDP, # lpszNewClusterName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszReason : LPCWSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn SetClusterNameEx(
hCluster: isize, // HCLUSTER
lpszNewClusterName: *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 SetClusterNameEx(IntPtr hCluster, [MarshalAs(UnmanagedType.LPWStr)] string lpszNewClusterName, [MarshalAs(UnmanagedType.LPWStr)] string lpszReason);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_SetClusterNameEx' -Namespace Win32 -PassThru
# $api::SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)#uselib "CLUSAPI.dll"
#func global SetClusterNameEx "SetClusterNameEx" sptr, sptr, sptr
; SetClusterNameEx hCluster, lpszNewClusterName, lpszReason ; 戻り値は stat
; hCluster : HCLUSTER -> "sptr"
; lpszNewClusterName : LPCWSTR -> "sptr"
; lpszReason : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CLUSAPI.dll"
#cfunc global SetClusterNameEx "SetClusterNameEx" sptr, wstr, wstr
; res = SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
; hCluster : HCLUSTER -> "sptr"
; lpszNewClusterName : LPCWSTR -> "wstr"
; lpszReason : LPCWSTR optional -> "wstr"; DWORD SetClusterNameEx(HCLUSTER hCluster, LPCWSTR lpszNewClusterName, LPCWSTR lpszReason)
#uselib "CLUSAPI.dll"
#cfunc global SetClusterNameEx "SetClusterNameEx" intptr, wstr, wstr
; res = SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
; hCluster : HCLUSTER -> "intptr"
; lpszNewClusterName : LPCWSTR -> "wstr"
; lpszReason : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procSetClusterNameEx = clusapi.NewProc("SetClusterNameEx")
)
// hCluster (HCLUSTER), lpszNewClusterName (LPCWSTR), lpszReason (LPCWSTR optional)
r1, _, err := procSetClusterNameEx.Call(
uintptr(hCluster),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszNewClusterName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszReason))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetClusterNameEx(
hCluster: NativeInt; // HCLUSTER
lpszNewClusterName: PWideChar; // LPCWSTR
lpszReason: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'SetClusterNameEx';result := DllCall("CLUSAPI\SetClusterNameEx"
, "Ptr", hCluster ; HCLUSTER
, "WStr", lpszNewClusterName ; LPCWSTR
, "WStr", lpszReason ; LPCWSTR optional
, "UInt") ; return: DWORD●SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason) = DLL("CLUSAPI.dll", "dword SetClusterNameEx(int, char*, char*)")
# 呼び出し: SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
# hCluster : HCLUSTER -> "int"
# lpszNewClusterName : LPCWSTR -> "char*"
# lpszReason : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clusapi" fn SetClusterNameEx(
hCluster: isize, // HCLUSTER
lpszNewClusterName: [*c]const u16, // LPCWSTR
lpszReason: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;proc SetClusterNameEx(
hCluster: int, # HCLUSTER
lpszNewClusterName: WideCString, # LPCWSTR
lpszReason: WideCString # LPCWSTR optional
): uint32 {.importc: "SetClusterNameEx", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
uint SetClusterNameEx(
ptrdiff_t hCluster, // HCLUSTER
const(wchar)* lpszNewClusterName, // LPCWSTR
const(wchar)* lpszReason // LPCWSTR optional
);ccall((:SetClusterNameEx, "CLUSAPI.dll"), stdcall, UInt32,
(Int, Cwstring, Cwstring),
hCluster, lpszNewClusterName, lpszReason)
# hCluster : HCLUSTER -> Int
# lpszNewClusterName : LPCWSTR -> Cwstring
# lpszReason : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SetClusterNameEx(
intptr_t hCluster,
const uint16_t* lpszNewClusterName,
const uint16_t* lpszReason);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
-- hCluster : HCLUSTER
-- lpszNewClusterName : LPCWSTR
-- lpszReason : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const SetClusterNameEx = lib.func('__stdcall', 'SetClusterNameEx', 'uint32_t', ['intptr_t', 'str16', 'str16']);
// SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
// hCluster : HCLUSTER -> 'intptr_t'
// lpszNewClusterName : LPCWSTR -> 'str16'
// lpszReason : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
SetClusterNameEx: { parameters: ["isize", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason)
// hCluster : HCLUSTER -> "isize"
// lpszNewClusterName : LPCWSTR -> "buffer"
// lpszReason : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SetClusterNameEx(
intptr_t hCluster,
const uint16_t* lpszNewClusterName,
const uint16_t* lpszReason);
C, "CLUSAPI.dll");
// $ffi->SetClusterNameEx(hCluster, lpszNewClusterName, lpszReason);
// hCluster : HCLUSTER
// lpszNewClusterName : LPCWSTR
// lpszReason : LPCWSTR optional
// 構造体/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 SetClusterNameEx(
long hCluster, // HCLUSTER
WString lpszNewClusterName, // LPCWSTR
WString lpszReason // LPCWSTR optional
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun SetClusterNameEx = SetClusterNameEx(
hCluster : LibC::SSizeT, # HCLUSTER
lpszNewClusterName : UInt16*, # LPCWSTR
lpszReason : UInt16* # LPCWSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetClusterNameExNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>);
typedef SetClusterNameExDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>);
final SetClusterNameEx = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<SetClusterNameExNative, SetClusterNameExDart>('SetClusterNameEx');
// hCluster : HCLUSTER -> IntPtr
// lpszNewClusterName : LPCWSTR -> Pointer<Utf16>
// lpszReason : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetClusterNameEx(
hCluster: NativeInt; // HCLUSTER
lpszNewClusterName: PWideChar; // LPCWSTR
lpszReason: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'CLUSAPI.dll' name 'SetClusterNameEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetClusterNameEx"
c_SetClusterNameEx :: CIntPtr -> CWString -> CWString -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- lpszNewClusterName : LPCWSTR -> CWString
-- lpszReason : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setclusternameex =
foreign "SetClusterNameEx"
(intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* lpszNewClusterName : LPCWSTR -> (ptr uint16_t) *)
(* lpszReason : LPCWSTR optional -> (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 ("SetClusterNameEx" set-cluster-name-ex :convention :stdcall) :uint32
(h-cluster :int64) ; HCLUSTER
(lpsz-new-cluster-name (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-reason (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetClusterNameEx = Win32::API::More->new('CLUSAPI',
'DWORD SetClusterNameEx(LPARAM hCluster, LPCWSTR lpszNewClusterName, LPCWSTR lpszReason)');
# my $ret = $SetClusterNameEx->Call($hCluster, $lpszNewClusterName, $lpszReason);
# hCluster : HCLUSTER -> LPARAM
# lpszNewClusterName : LPCWSTR -> LPCWSTR
# lpszReason : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f SetClusterName — クラスターの名前を変更する。