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

AddCrossClusterGroupSetDependency

関数
別クラスターのグループセットへの依存関係を追加する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD AddCrossClusterGroupSetDependency(
    HGROUPSET hDependentGroupSet,
    LPCWSTR lpRemoteClusterName,
    LPCWSTR lpRemoteGroupSetName
);

パラメーター

名前方向説明
hDependentGroupSetHGROUPSETin依存する側(従属)のローカルグループセットへのハンドル。
lpRemoteClusterNameLPCWSTRin依存先となるリモートクラスタ名を指すワイド文字列。
lpRemoteGroupSetNameLPCWSTRin依存先となるリモートグループセット名を指すワイド文字列。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

AddCrossClusterGroupSetDependency = ctypes.windll.clusapi.AddCrossClusterGroupSetDependency
AddCrossClusterGroupSetDependency.restype = wintypes.DWORD
AddCrossClusterGroupSetDependency.argtypes = [
    ctypes.c_ssize_t,  # hDependentGroupSet : HGROUPSET
    wintypes.LPCWSTR,  # lpRemoteClusterName : LPCWSTR
    wintypes.LPCWSTR,  # lpRemoteGroupSetName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procAddCrossClusterGroupSetDependency = clusapi.NewProc("AddCrossClusterGroupSetDependency")
)

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

extern "clusapi" fn AddCrossClusterGroupSetDependency(
    hDependentGroupSet: isize, // HGROUPSET
    lpRemoteClusterName: [*c]const u16, // LPCWSTR
    lpRemoteGroupSetName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;
proc AddCrossClusterGroupSetDependency(
    hDependentGroupSet: int,  # HGROUPSET
    lpRemoteClusterName: WideCString,  # LPCWSTR
    lpRemoteGroupSetName: WideCString  # LPCWSTR
): uint32 {.importc: "AddCrossClusterGroupSetDependency", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
uint AddCrossClusterGroupSetDependency(
    ptrdiff_t hDependentGroupSet,   // HGROUPSET
    const(wchar)* lpRemoteClusterName,   // LPCWSTR
    const(wchar)* lpRemoteGroupSetName   // LPCWSTR
);
ccall((:AddCrossClusterGroupSetDependency, "CLUSAPI.dll"), stdcall, UInt32,
      (Int, Cwstring, Cwstring),
      hDependentGroupSet, lpRemoteClusterName, lpRemoteGroupSetName)
# hDependentGroupSet : HGROUPSET -> Int
# lpRemoteClusterName : LPCWSTR -> Cwstring
# lpRemoteGroupSetName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t AddCrossClusterGroupSetDependency(
    intptr_t hDependentGroupSet,
    const uint16_t* lpRemoteClusterName,
    const uint16_t* lpRemoteGroupSetName);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.AddCrossClusterGroupSetDependency(hDependentGroupSet, lpRemoteClusterName, lpRemoteGroupSetName)
-- hDependentGroupSet : HGROUPSET
-- lpRemoteClusterName : LPCWSTR
-- lpRemoteGroupSetName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const AddCrossClusterGroupSetDependency = lib.func('__stdcall', 'AddCrossClusterGroupSetDependency', 'uint32_t', ['intptr_t', 'str16', 'str16']);
// AddCrossClusterGroupSetDependency(hDependentGroupSet, lpRemoteClusterName, lpRemoteGroupSetName)
// hDependentGroupSet : HGROUPSET -> 'intptr_t'
// lpRemoteClusterName : LPCWSTR -> 'str16'
// lpRemoteGroupSetName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  AddCrossClusterGroupSetDependency: { parameters: ["isize", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.AddCrossClusterGroupSetDependency(hDependentGroupSet, lpRemoteClusterName, lpRemoteGroupSetName)
// hDependentGroupSet : HGROUPSET -> "isize"
// lpRemoteClusterName : LPCWSTR -> "buffer"
// lpRemoteGroupSetName : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t AddCrossClusterGroupSetDependency(
    intptr_t hDependentGroupSet,
    const uint16_t* lpRemoteClusterName,
    const uint16_t* lpRemoteGroupSetName);
C, "CLUSAPI.dll");
// $ffi->AddCrossClusterGroupSetDependency(hDependentGroupSet, lpRemoteClusterName, lpRemoteGroupSetName);
// hDependentGroupSet : HGROUPSET
// lpRemoteClusterName : LPCWSTR
// lpRemoteGroupSetName : 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 AddCrossClusterGroupSetDependency(
        long hDependentGroupSet,   // HGROUPSET
        WString lpRemoteClusterName,   // LPCWSTR
        WString lpRemoteGroupSetName   // LPCWSTR
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun AddCrossClusterGroupSetDependency = AddCrossClusterGroupSetDependency(
    hDependentGroupSet : LibC::SSizeT,   # HGROUPSET
    lpRemoteClusterName : UInt16*,   # LPCWSTR
    lpRemoteGroupSetName : 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 AddCrossClusterGroupSetDependencyNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>);
typedef AddCrossClusterGroupSetDependencyDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>);
final AddCrossClusterGroupSetDependency = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<AddCrossClusterGroupSetDependencyNative, AddCrossClusterGroupSetDependencyDart>('AddCrossClusterGroupSetDependency');
// hDependentGroupSet : HGROUPSET -> IntPtr
// lpRemoteClusterName : LPCWSTR -> Pointer<Utf16>
// lpRemoteGroupSetName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function AddCrossClusterGroupSetDependency(
  hDependentGroupSet: NativeInt;   // HGROUPSET
  lpRemoteClusterName: PWideChar;   // LPCWSTR
  lpRemoteGroupSetName: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'AddCrossClusterGroupSetDependency';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "AddCrossClusterGroupSetDependency"
  c_AddCrossClusterGroupSetDependency :: CIntPtr -> CWString -> CWString -> IO Word32
-- hDependentGroupSet : HGROUPSET -> CIntPtr
-- lpRemoteClusterName : LPCWSTR -> CWString
-- lpRemoteGroupSetName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let addcrossclustergroupsetdependency =
  foreign "AddCrossClusterGroupSetDependency"
    (intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* hDependentGroupSet : HGROUPSET -> intptr_t *)
(* lpRemoteClusterName : LPCWSTR -> (ptr uint16_t) *)
(* lpRemoteGroupSetName : 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 ("AddCrossClusterGroupSetDependency" add-cross-cluster-group-set-dependency :convention :stdcall) :uint32
  (h-dependent-group-set :int64)   ; HGROUPSET
  (lp-remote-cluster-name (:string :encoding :utf-16le))   ; LPCWSTR
  (lp-remote-group-set-name (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $AddCrossClusterGroupSetDependency = Win32::API::More->new('CLUSAPI',
    'DWORD AddCrossClusterGroupSetDependency(LPARAM hDependentGroupSet, LPCWSTR lpRemoteClusterName, LPCWSTR lpRemoteGroupSetName)');
# my $ret = $AddCrossClusterGroupSetDependency->Call($hDependentGroupSet, $lpRemoteClusterName, $lpRemoteGroupSetName);
# hDependentGroupSet : HGROUPSET -> LPARAM
# lpRemoteClusterName : LPCWSTR -> LPCWSTR
# lpRemoteGroupSetName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。