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

DsReplicaUpdateRefsW

関数
複製先サーバーへの参照を更新する(Unicode版)。
DLLNTDSAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// NTDSAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD DsReplicaUpdateRefsW(
    HANDLE hDS,
    LPCWSTR NameContext,
    LPCWSTR DsaDest,
    const GUID* pUuidDsaDest,
    DWORD Options
);

パラメーター

名前方向
hDSHANDLEin
NameContextLPCWSTRin
DsaDestLPCWSTRin
pUuidDsaDestGUID*in
OptionsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// NTDSAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD DsReplicaUpdateRefsW(
    HANDLE hDS,
    LPCWSTR NameContext,
    LPCWSTR DsaDest,
    const GUID* pUuidDsaDest,
    DWORD Options
);
[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsReplicaUpdateRefsW(
    IntPtr hDS,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string NameContext,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string DsaDest,   // LPCWSTR
    ref Guid pUuidDsaDest,   // GUID*
    uint Options   // DWORD
);
<DllImport("NTDSAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsReplicaUpdateRefsW(
    hDS As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> NameContext As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> DsaDest As String,   ' LPCWSTR
    ByRef pUuidDsaDest As Guid,   ' GUID*
    Options As UInteger   ' DWORD
) As UInteger
End Function
' hDS : HANDLE
' NameContext : LPCWSTR
' DsaDest : LPCWSTR
' pUuidDsaDest : GUID*
' Options : DWORD
Declare PtrSafe Function DsReplicaUpdateRefsW Lib "ntdsapi" ( _
    ByVal hDS As LongPtr, _
    ByVal NameContext As LongPtr, _
    ByVal DsaDest As LongPtr, _
    ByVal pUuidDsaDest As LongPtr, _
    ByVal Options As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DsReplicaUpdateRefsW = ctypes.windll.ntdsapi.DsReplicaUpdateRefsW
DsReplicaUpdateRefsW.restype = wintypes.DWORD
DsReplicaUpdateRefsW.argtypes = [
    wintypes.HANDLE,  # hDS : HANDLE
    wintypes.LPCWSTR,  # NameContext : LPCWSTR
    wintypes.LPCWSTR,  # DsaDest : LPCWSTR
    ctypes.c_void_p,  # pUuidDsaDest : GUID*
    wintypes.DWORD,  # Options : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NTDSAPI.dll')
DsReplicaUpdateRefsW = Fiddle::Function.new(
  lib['DsReplicaUpdateRefsW'],
  [
    Fiddle::TYPE_VOIDP,  # hDS : HANDLE
    Fiddle::TYPE_VOIDP,  # NameContext : LPCWSTR
    Fiddle::TYPE_VOIDP,  # DsaDest : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pUuidDsaDest : GUID*
    -Fiddle::TYPE_INT,  # Options : DWORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "ntdsapi")]
extern "system" {
    fn DsReplicaUpdateRefsW(
        hDS: *mut core::ffi::c_void,  // HANDLE
        NameContext: *const u16,  // LPCWSTR
        DsaDest: *const u16,  // LPCWSTR
        pUuidDsaDest: *const GUID,  // GUID*
        Options: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode)]
public static extern uint DsReplicaUpdateRefsW(IntPtr hDS, [MarshalAs(UnmanagedType.LPWStr)] string NameContext, [MarshalAs(UnmanagedType.LPWStr)] string DsaDest, ref Guid pUuidDsaDest, uint Options);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsReplicaUpdateRefsW' -Namespace Win32 -PassThru
# $api::DsReplicaUpdateRefsW(hDS, NameContext, DsaDest, pUuidDsaDest, Options)
#uselib "NTDSAPI.dll"
#func global DsReplicaUpdateRefsW "DsReplicaUpdateRefsW" wptr, wptr, wptr, wptr, wptr
; DsReplicaUpdateRefsW hDS, NameContext, DsaDest, varptr(pUuidDsaDest), Options   ; 戻り値は stat
; hDS : HANDLE -> "wptr"
; NameContext : LPCWSTR -> "wptr"
; DsaDest : LPCWSTR -> "wptr"
; pUuidDsaDest : GUID* -> "wptr"
; Options : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NTDSAPI.dll"
#cfunc global DsReplicaUpdateRefsW "DsReplicaUpdateRefsW" sptr, wstr, wstr, var, int
; res = DsReplicaUpdateRefsW(hDS, NameContext, DsaDest, pUuidDsaDest, Options)
; hDS : HANDLE -> "sptr"
; NameContext : LPCWSTR -> "wstr"
; DsaDest : LPCWSTR -> "wstr"
; pUuidDsaDest : GUID* -> "var"
; Options : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DsReplicaUpdateRefsW(HANDLE hDS, LPCWSTR NameContext, LPCWSTR DsaDest, GUID* pUuidDsaDest, DWORD Options)
#uselib "NTDSAPI.dll"
#cfunc global DsReplicaUpdateRefsW "DsReplicaUpdateRefsW" intptr, wstr, wstr, var, int
; res = DsReplicaUpdateRefsW(hDS, NameContext, DsaDest, pUuidDsaDest, Options)
; hDS : HANDLE -> "intptr"
; NameContext : LPCWSTR -> "wstr"
; DsaDest : LPCWSTR -> "wstr"
; pUuidDsaDest : GUID* -> "var"
; Options : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
	procDsReplicaUpdateRefsW = ntdsapi.NewProc("DsReplicaUpdateRefsW")
)

// hDS (HANDLE), NameContext (LPCWSTR), DsaDest (LPCWSTR), pUuidDsaDest (GUID*), Options (DWORD)
r1, _, err := procDsReplicaUpdateRefsW.Call(
	uintptr(hDS),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(NameContext))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DsaDest))),
	uintptr(pUuidDsaDest),
	uintptr(Options),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsReplicaUpdateRefsW(
  hDS: THandle;   // HANDLE
  NameContext: PWideChar;   // LPCWSTR
  DsaDest: PWideChar;   // LPCWSTR
  pUuidDsaDest: PGUID;   // GUID*
  Options: DWORD   // DWORD
): DWORD; stdcall;
  external 'NTDSAPI.dll' name 'DsReplicaUpdateRefsW';
result := DllCall("NTDSAPI\DsReplicaUpdateRefsW"
    , "Ptr", hDS   ; HANDLE
    , "WStr", NameContext   ; LPCWSTR
    , "WStr", DsaDest   ; LPCWSTR
    , "Ptr", pUuidDsaDest   ; GUID*
    , "UInt", Options   ; DWORD
    , "UInt")   ; return: DWORD
●DsReplicaUpdateRefsW(hDS, NameContext, DsaDest, pUuidDsaDest, Options) = DLL("NTDSAPI.dll", "dword DsReplicaUpdateRefsW(void*, char*, char*, void*, dword)")
# 呼び出し: DsReplicaUpdateRefsW(hDS, NameContext, DsaDest, pUuidDsaDest, Options)
# hDS : HANDLE -> "void*"
# NameContext : LPCWSTR -> "char*"
# DsaDest : LPCWSTR -> "char*"
# pUuidDsaDest : GUID* -> "void*"
# Options : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。