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