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

AddClusterResourceDependencyEx

関数
理由付きでクラスターリソースに依存関係を追加する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD AddClusterResourceDependencyEx(
    HRESOURCE hResource,
    HRESOURCE hDependsOn,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hResourceHRESOURCEin
hDependsOnHRESOURCEin
lpszReasonLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD AddClusterResourceDependencyEx(
    HRESOURCE hResource,
    HRESOURCE hDependsOn,
    LPCWSTR lpszReason   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint AddClusterResourceDependencyEx(
    IntPtr hResource,   // HRESOURCE
    IntPtr hDependsOn,   // HRESOURCE
    [MarshalAs(UnmanagedType.LPWStr)] string lpszReason   // LPCWSTR optional
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function AddClusterResourceDependencyEx(
    hResource As IntPtr,   ' HRESOURCE
    hDependsOn As IntPtr,   ' HRESOURCE
    <MarshalAs(UnmanagedType.LPWStr)> lpszReason As String   ' LPCWSTR optional
) As UInteger
End Function
' hResource : HRESOURCE
' hDependsOn : HRESOURCE
' lpszReason : LPCWSTR optional
Declare PtrSafe Function AddClusterResourceDependencyEx Lib "clusapi" ( _
    ByVal hResource As LongPtr, _
    ByVal hDependsOn 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

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

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procAddClusterResourceDependencyEx = clusapi.NewProc("AddClusterResourceDependencyEx")
)

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