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

CreateClusterResourceEx

関数
理由付きでグループ内にクラスターリソースを作成する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

HRESOURCE CreateClusterResourceEx(
    HGROUP hGroup,
    LPCWSTR lpszResourceName,
    LPCWSTR lpszResourceType,
    DWORD dwFlags,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向説明
hGroupHGROUPinリソースを作成し所属させる対象グループのハンドル。
lpszResourceNameLPCWSTRin作成するリソースの名前を示すワイド文字列。
lpszResourceTypeLPCWSTRinリソースの種類を示すリソースタイプ名のワイド文字列。
dwFlagsDWORDin作成動作を制御するフラグ。CLUSTER_RESOURCE_*値で指定する。
lpszReasonLPCWSTRinoptional操作の理由を示すワイド文字列。監査ログ用で、NULL可。

戻り値の型: HRESOURCE

各言語での呼び出し定義

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

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

CreateClusterResourceEx = ctypes.windll.clusapi.CreateClusterResourceEx
CreateClusterResourceEx.restype = ctypes.c_ssize_t
CreateClusterResourceEx.argtypes = [
    ctypes.c_ssize_t,  # hGroup : HGROUP
    wintypes.LPCWSTR,  # lpszResourceName : LPCWSTR
    wintypes.LPCWSTR,  # lpszResourceType : LPCWSTR
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procCreateClusterResourceEx = clusapi.NewProc("CreateClusterResourceEx")
)

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

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

typedef CreateClusterResourceExNative = IntPtr Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Utf16>);
typedef CreateClusterResourceExDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Utf16>);
final CreateClusterResourceEx = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<CreateClusterResourceExNative, CreateClusterResourceExDart>('CreateClusterResourceEx');
// hGroup : HGROUP -> IntPtr
// lpszResourceName : LPCWSTR -> Pointer<Utf16>
// lpszResourceType : LPCWSTR -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// lpszReason : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateClusterResourceEx(
  hGroup: NativeInt;   // HGROUP
  lpszResourceName: PWideChar;   // LPCWSTR
  lpszResourceType: PWideChar;   // LPCWSTR
  dwFlags: DWORD;   // DWORD
  lpszReason: PWideChar   // LPCWSTR optional
): NativeInt; stdcall;
  external 'CLUSAPI.dll' name 'CreateClusterResourceEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreateClusterResourceEx"
  c_CreateClusterResourceEx :: CIntPtr -> CWString -> CWString -> Word32 -> CWString -> IO CIntPtr
-- hGroup : HGROUP -> CIntPtr
-- lpszResourceName : LPCWSTR -> CWString
-- lpszResourceType : LPCWSTR -> CWString
-- dwFlags : DWORD -> Word32
-- lpszReason : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createclusterresourceex =
  foreign "CreateClusterResourceEx"
    (intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> returning intptr_t)
(* hGroup : HGROUP -> intptr_t *)
(* lpszResourceName : LPCWSTR -> (ptr uint16_t) *)
(* lpszResourceType : LPCWSTR -> (ptr uint16_t) *)
(* dwFlags : DWORD -> uint32_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 ("CreateClusterResourceEx" create-cluster-resource-ex :convention :stdcall) :int64
  (h-group :int64)   ; HGROUP
  (lpsz-resource-name (:string :encoding :utf-16le))   ; LPCWSTR
  (lpsz-resource-type (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-flags :uint32)   ; DWORD
  (lpsz-reason (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateClusterResourceEx = Win32::API::More->new('CLUSAPI',
    'LPARAM CreateClusterResourceEx(LPARAM hGroup, LPCWSTR lpszResourceName, LPCWSTR lpszResourceType, DWORD dwFlags, LPCWSTR lpszReason)');
# my $ret = $CreateClusterResourceEx->Call($hGroup, $lpszResourceName, $lpszResourceType, $dwFlags, $lpszReason);
# hGroup : HGROUP -> LPARAM
# lpszResourceName : LPCWSTR -> LPCWSTR
# lpszResourceType : LPCWSTR -> LPCWSTR
# dwFlags : DWORD -> DWORD
# lpszReason : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API