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

ChangeClusterResourceGroupEx2

関数
理由付きでクラスターリソースを別グループへ移動する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ChangeClusterResourceGroupEx2(
    HRESOURCE hResource,
    HGROUP hGroup,
    ULONGLONG Flags,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hResourceHRESOURCEin
hGroupHGROUPin
FlagsULONGLONGin
lpszReasonLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

ChangeClusterResourceGroupEx2 = ctypes.windll.clusapi.ChangeClusterResourceGroupEx2
ChangeClusterResourceGroupEx2.restype = wintypes.DWORD
ChangeClusterResourceGroupEx2.argtypes = [
    ctypes.c_ssize_t,  # hResource : HRESOURCE
    ctypes.c_ssize_t,  # hGroup : HGROUP
    ctypes.c_ulonglong,  # Flags : ULONGLONG
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ChangeClusterResourceGroupEx2 = Fiddle::Function.new(
  lib['ChangeClusterResourceGroupEx2'],
  [
    Fiddle::TYPE_INTPTR_T,  # hResource : HRESOURCE
    Fiddle::TYPE_INTPTR_T,  # hGroup : HGROUP
    -Fiddle::TYPE_LONG_LONG,  # Flags : ULONGLONG
    Fiddle::TYPE_VOIDP,  # lpszReason : LPCWSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ChangeClusterResourceGroupEx2(
        hResource: isize,  // HRESOURCE
        hGroup: isize,  // HGROUP
        Flags: u64,  // ULONGLONG
        lpszReason: *const u16  // LPCWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint ChangeClusterResourceGroupEx2(IntPtr hResource, IntPtr hGroup, ulong Flags, [MarshalAs(UnmanagedType.LPWStr)] string lpszReason);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ChangeClusterResourceGroupEx2' -Namespace Win32 -PassThru
# $api::ChangeClusterResourceGroupEx2(hResource, hGroup, Flags, lpszReason)
#uselib "CLUSAPI.dll"
#func global ChangeClusterResourceGroupEx2 "ChangeClusterResourceGroupEx2" sptr, sptr, sptr, sptr
; ChangeClusterResourceGroupEx2 hResource, hGroup, Flags, lpszReason   ; 戻り値は stat
; hResource : HRESOURCE -> "sptr"
; hGroup : HGROUP -> "sptr"
; Flags : ULONGLONG -> "sptr"
; lpszReason : LPCWSTR optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global ChangeClusterResourceGroupEx2 "ChangeClusterResourceGroupEx2" sptr, sptr, int64, wstr
; res = ChangeClusterResourceGroupEx2(hResource, hGroup, Flags, lpszReason)
; hResource : HRESOURCE -> "sptr"
; hGroup : HGROUP -> "sptr"
; Flags : ULONGLONG -> "int64"
; lpszReason : LPCWSTR optional -> "wstr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; DWORD ChangeClusterResourceGroupEx2(HRESOURCE hResource, HGROUP hGroup, ULONGLONG Flags, LPCWSTR lpszReason)
#uselib "CLUSAPI.dll"
#cfunc global ChangeClusterResourceGroupEx2 "ChangeClusterResourceGroupEx2" intptr, intptr, int64, wstr
; res = ChangeClusterResourceGroupEx2(hResource, hGroup, Flags, lpszReason)
; hResource : HRESOURCE -> "intptr"
; hGroup : HGROUP -> "intptr"
; Flags : ULONGLONG -> "int64"
; lpszReason : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procChangeClusterResourceGroupEx2 = clusapi.NewProc("ChangeClusterResourceGroupEx2")
)

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