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

SetClusterQuorumResource

関数
クラスターのクォーラムリソースを設定する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD SetClusterQuorumResource(
    HRESOURCE hResource,
    LPCWSTR lpszDeviceName,   // optional
    DWORD dwMaxQuoLogSize
);

パラメーター

名前方向説明
hResourceHRESOURCEinクォーラムに設定するリソースへのハンドル。
lpszDeviceNameLPCWSTRinoptionalクォーラムデバイス名(パーティション)を指すワイド文字列。
dwMaxQuoLogSizeDWORDinクォーラムログの最大サイズ(バイト)を指定する。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

SetClusterQuorumResource = ctypes.windll.clusapi.SetClusterQuorumResource
SetClusterQuorumResource.restype = wintypes.DWORD
SetClusterQuorumResource.argtypes = [
    ctypes.c_ssize_t,  # hResource : HRESOURCE
    wintypes.LPCWSTR,  # lpszDeviceName : LPCWSTR optional
    wintypes.DWORD,  # dwMaxQuoLogSize : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procSetClusterQuorumResource = clusapi.NewProc("SetClusterQuorumResource")
)

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

extern "clusapi" fn SetClusterQuorumResource(
    hResource: isize, // HRESOURCE
    lpszDeviceName: [*c]const u16, // LPCWSTR optional
    dwMaxQuoLogSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc SetClusterQuorumResource(
    hResource: int,  # HRESOURCE
    lpszDeviceName: WideCString,  # LPCWSTR optional
    dwMaxQuoLogSize: uint32  # DWORD
): uint32 {.importc: "SetClusterQuorumResource", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
uint SetClusterQuorumResource(
    ptrdiff_t hResource,   // HRESOURCE
    const(wchar)* lpszDeviceName,   // LPCWSTR optional
    uint dwMaxQuoLogSize   // DWORD
);
ccall((:SetClusterQuorumResource, "CLUSAPI.dll"), stdcall, UInt32,
      (Int, Cwstring, UInt32),
      hResource, lpszDeviceName, dwMaxQuoLogSize)
# hResource : HRESOURCE -> Int
# lpszDeviceName : LPCWSTR optional -> Cwstring
# dwMaxQuoLogSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t SetClusterQuorumResource(
    intptr_t hResource,
    const uint16_t* lpszDeviceName,
    uint32_t dwMaxQuoLogSize);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.SetClusterQuorumResource(hResource, lpszDeviceName, dwMaxQuoLogSize)
-- hResource : HRESOURCE
-- lpszDeviceName : LPCWSTR optional
-- dwMaxQuoLogSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const SetClusterQuorumResource = lib.func('__stdcall', 'SetClusterQuorumResource', 'uint32_t', ['intptr_t', 'str16', 'uint32_t']);
// SetClusterQuorumResource(hResource, lpszDeviceName, dwMaxQuoLogSize)
// hResource : HRESOURCE -> 'intptr_t'
// lpszDeviceName : LPCWSTR optional -> 'str16'
// dwMaxQuoLogSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  SetClusterQuorumResource: { parameters: ["isize", "buffer", "u32"], result: "u32" },
});
// lib.symbols.SetClusterQuorumResource(hResource, lpszDeviceName, dwMaxQuoLogSize)
// hResource : HRESOURCE -> "isize"
// lpszDeviceName : LPCWSTR optional -> "buffer"
// dwMaxQuoLogSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t SetClusterQuorumResource(
    intptr_t hResource,
    const uint16_t* lpszDeviceName,
    uint32_t dwMaxQuoLogSize);
C, "CLUSAPI.dll");
// $ffi->SetClusterQuorumResource(hResource, lpszDeviceName, dwMaxQuoLogSize);
// hResource : HRESOURCE
// lpszDeviceName : LPCWSTR optional
// dwMaxQuoLogSize : DWORD
// 構造体/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 SetClusterQuorumResource(
        long hResource,   // HRESOURCE
        WString lpszDeviceName,   // LPCWSTR optional
        int dwMaxQuoLogSize   // DWORD
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun SetClusterQuorumResource = SetClusterQuorumResource(
    hResource : LibC::SSizeT,   # HRESOURCE
    lpszDeviceName : UInt16*,   # LPCWSTR optional
    dwMaxQuoLogSize : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetClusterQuorumResourceNative = Uint32 Function(IntPtr, Pointer<Utf16>, Uint32);
typedef SetClusterQuorumResourceDart = int Function(int, Pointer<Utf16>, int);
final SetClusterQuorumResource = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<SetClusterQuorumResourceNative, SetClusterQuorumResourceDart>('SetClusterQuorumResource');
// hResource : HRESOURCE -> IntPtr
// lpszDeviceName : LPCWSTR optional -> Pointer<Utf16>
// dwMaxQuoLogSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetClusterQuorumResource(
  hResource: NativeInt;   // HRESOURCE
  lpszDeviceName: PWideChar;   // LPCWSTR optional
  dwMaxQuoLogSize: DWORD   // DWORD
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'SetClusterQuorumResource';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetClusterQuorumResource"
  c_SetClusterQuorumResource :: CIntPtr -> CWString -> Word32 -> IO Word32
-- hResource : HRESOURCE -> CIntPtr
-- lpszDeviceName : LPCWSTR optional -> CWString
-- dwMaxQuoLogSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setclusterquorumresource =
  foreign "SetClusterQuorumResource"
    (intptr_t @-> (ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* hResource : HRESOURCE -> intptr_t *)
(* lpszDeviceName : LPCWSTR optional -> (ptr uint16_t) *)
(* dwMaxQuoLogSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("SetClusterQuorumResource" set-cluster-quorum-resource :convention :stdcall) :uint32
  (h-resource :int64)   ; HRESOURCE
  (lpsz-device-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (dw-max-quo-log-size :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetClusterQuorumResource = Win32::API::More->new('CLUSAPI',
    'DWORD SetClusterQuorumResource(LPARAM hResource, LPCWSTR lpszDeviceName, DWORD dwMaxQuoLogSize)');
# my $ret = $SetClusterQuorumResource->Call($hResource, $lpszDeviceName, $dwMaxQuoLogSize);
# hResource : HRESOURCE -> LPARAM
# lpszDeviceName : LPCWSTR optional -> LPCWSTR
# dwMaxQuoLogSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API