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

DsReplicaGetInfo2W

関数
属性や列挙コンテキストを指定して詳細なレプリケーション情報を取得する。
DLLNTDSAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD DsReplicaGetInfo2W(
    HANDLE hDS,
    DS_REPL_INFO_TYPE InfoType,
    LPCWSTR pszObject,   // optional
    GUID* puuidForSourceDsaObjGuid,   // optional
    LPCWSTR pszAttributeName,   // optional
    LPCWSTR pszValue,   // optional
    DWORD dwFlags,
    DWORD dwEnumerationContext,
    void** ppInfo
);

パラメーター

名前方向
hDSHANDLEin
InfoTypeDS_REPL_INFO_TYPEin
pszObjectLPCWSTRinoptional
puuidForSourceDsaObjGuidGUID*inoptional
pszAttributeNameLPCWSTRinoptional
pszValueLPCWSTRinoptional
dwFlagsDWORDin
dwEnumerationContextDWORDin
ppInfovoid**out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DsReplicaGetInfo2W(
    HANDLE hDS,
    DS_REPL_INFO_TYPE InfoType,
    LPCWSTR pszObject,   // optional
    GUID* puuidForSourceDsaObjGuid,   // optional
    LPCWSTR pszAttributeName,   // optional
    LPCWSTR pszValue,   // optional
    DWORD dwFlags,
    DWORD dwEnumerationContext,
    void** ppInfo
);
[DllImport("NTDSAPI.dll", ExactSpelling = true)]
static extern uint DsReplicaGetInfo2W(
    IntPtr hDS,   // HANDLE
    int InfoType,   // DS_REPL_INFO_TYPE
    [MarshalAs(UnmanagedType.LPWStr)] string pszObject,   // LPCWSTR optional
    IntPtr puuidForSourceDsaObjGuid,   // GUID* optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszAttributeName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszValue,   // LPCWSTR optional
    uint dwFlags,   // DWORD
    uint dwEnumerationContext,   // DWORD
    IntPtr ppInfo   // void** out
);
<DllImport("NTDSAPI.dll", ExactSpelling:=True)>
Public Shared Function DsReplicaGetInfo2W(
    hDS As IntPtr,   ' HANDLE
    InfoType As Integer,   ' DS_REPL_INFO_TYPE
    <MarshalAs(UnmanagedType.LPWStr)> pszObject As String,   ' LPCWSTR optional
    puuidForSourceDsaObjGuid As IntPtr,   ' GUID* optional
    <MarshalAs(UnmanagedType.LPWStr)> pszAttributeName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pszValue As String,   ' LPCWSTR optional
    dwFlags As UInteger,   ' DWORD
    dwEnumerationContext As UInteger,   ' DWORD
    ppInfo As IntPtr   ' void** out
) As UInteger
End Function
' hDS : HANDLE
' InfoType : DS_REPL_INFO_TYPE
' pszObject : LPCWSTR optional
' puuidForSourceDsaObjGuid : GUID* optional
' pszAttributeName : LPCWSTR optional
' pszValue : LPCWSTR optional
' dwFlags : DWORD
' dwEnumerationContext : DWORD
' ppInfo : void** out
Declare PtrSafe Function DsReplicaGetInfo2W Lib "ntdsapi" ( _
    ByVal hDS As LongPtr, _
    ByVal InfoType As Long, _
    ByVal pszObject As LongPtr, _
    ByVal puuidForSourceDsaObjGuid As LongPtr, _
    ByVal pszAttributeName As LongPtr, _
    ByVal pszValue As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal dwEnumerationContext As Long, _
    ByVal ppInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DsReplicaGetInfo2W = ctypes.windll.ntdsapi.DsReplicaGetInfo2W
DsReplicaGetInfo2W.restype = wintypes.DWORD
DsReplicaGetInfo2W.argtypes = [
    wintypes.HANDLE,  # hDS : HANDLE
    ctypes.c_int,  # InfoType : DS_REPL_INFO_TYPE
    wintypes.LPCWSTR,  # pszObject : LPCWSTR optional
    ctypes.c_void_p,  # puuidForSourceDsaObjGuid : GUID* optional
    wintypes.LPCWSTR,  # pszAttributeName : LPCWSTR optional
    wintypes.LPCWSTR,  # pszValue : LPCWSTR optional
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.DWORD,  # dwEnumerationContext : DWORD
    ctypes.c_void_p,  # ppInfo : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NTDSAPI.dll')
DsReplicaGetInfo2W = Fiddle::Function.new(
  lib['DsReplicaGetInfo2W'],
  [
    Fiddle::TYPE_VOIDP,  # hDS : HANDLE
    Fiddle::TYPE_INT,  # InfoType : DS_REPL_INFO_TYPE
    Fiddle::TYPE_VOIDP,  # pszObject : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # puuidForSourceDsaObjGuid : GUID* optional
    Fiddle::TYPE_VOIDP,  # pszAttributeName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pszValue : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    -Fiddle::TYPE_INT,  # dwEnumerationContext : DWORD
    Fiddle::TYPE_VOIDP,  # ppInfo : void** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "ntdsapi")]
extern "system" {
    fn DsReplicaGetInfo2W(
        hDS: *mut core::ffi::c_void,  // HANDLE
        InfoType: i32,  // DS_REPL_INFO_TYPE
        pszObject: *const u16,  // LPCWSTR optional
        puuidForSourceDsaObjGuid: *mut GUID,  // GUID* optional
        pszAttributeName: *const u16,  // LPCWSTR optional
        pszValue: *const u16,  // LPCWSTR optional
        dwFlags: u32,  // DWORD
        dwEnumerationContext: u32,  // DWORD
        ppInfo: *mut *mut ()  // void** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NTDSAPI.dll")]
public static extern uint DsReplicaGetInfo2W(IntPtr hDS, int InfoType, [MarshalAs(UnmanagedType.LPWStr)] string pszObject, IntPtr puuidForSourceDsaObjGuid, [MarshalAs(UnmanagedType.LPWStr)] string pszAttributeName, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, uint dwFlags, uint dwEnumerationContext, IntPtr ppInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsReplicaGetInfo2W' -Namespace Win32 -PassThru
# $api::DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo)
#uselib "NTDSAPI.dll"
#func global DsReplicaGetInfo2W "DsReplicaGetInfo2W" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DsReplicaGetInfo2W hDS, InfoType, pszObject, varptr(puuidForSourceDsaObjGuid), pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo   ; 戻り値は stat
; hDS : HANDLE -> "sptr"
; InfoType : DS_REPL_INFO_TYPE -> "sptr"
; pszObject : LPCWSTR optional -> "sptr"
; puuidForSourceDsaObjGuid : GUID* optional -> "sptr"
; pszAttributeName : LPCWSTR optional -> "sptr"
; pszValue : LPCWSTR optional -> "sptr"
; dwFlags : DWORD -> "sptr"
; dwEnumerationContext : DWORD -> "sptr"
; ppInfo : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NTDSAPI.dll"
#cfunc global DsReplicaGetInfo2W "DsReplicaGetInfo2W" sptr, int, wstr, var, wstr, wstr, int, int, sptr
; res = DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo)
; hDS : HANDLE -> "sptr"
; InfoType : DS_REPL_INFO_TYPE -> "int"
; pszObject : LPCWSTR optional -> "wstr"
; puuidForSourceDsaObjGuid : GUID* optional -> "var"
; pszAttributeName : LPCWSTR optional -> "wstr"
; pszValue : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; dwEnumerationContext : DWORD -> "int"
; ppInfo : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DsReplicaGetInfo2W(HANDLE hDS, DS_REPL_INFO_TYPE InfoType, LPCWSTR pszObject, GUID* puuidForSourceDsaObjGuid, LPCWSTR pszAttributeName, LPCWSTR pszValue, DWORD dwFlags, DWORD dwEnumerationContext, void** ppInfo)
#uselib "NTDSAPI.dll"
#cfunc global DsReplicaGetInfo2W "DsReplicaGetInfo2W" intptr, int, wstr, var, wstr, wstr, int, int, intptr
; res = DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo)
; hDS : HANDLE -> "intptr"
; InfoType : DS_REPL_INFO_TYPE -> "int"
; pszObject : LPCWSTR optional -> "wstr"
; puuidForSourceDsaObjGuid : GUID* optional -> "var"
; pszAttributeName : LPCWSTR optional -> "wstr"
; pszValue : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; dwEnumerationContext : DWORD -> "int"
; ppInfo : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
	procDsReplicaGetInfo2W = ntdsapi.NewProc("DsReplicaGetInfo2W")
)

// hDS (HANDLE), InfoType (DS_REPL_INFO_TYPE), pszObject (LPCWSTR optional), puuidForSourceDsaObjGuid (GUID* optional), pszAttributeName (LPCWSTR optional), pszValue (LPCWSTR optional), dwFlags (DWORD), dwEnumerationContext (DWORD), ppInfo (void** out)
r1, _, err := procDsReplicaGetInfo2W.Call(
	uintptr(hDS),
	uintptr(InfoType),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszObject))),
	uintptr(puuidForSourceDsaObjGuid),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszAttributeName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValue))),
	uintptr(dwFlags),
	uintptr(dwEnumerationContext),
	uintptr(ppInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsReplicaGetInfo2W(
  hDS: THandle;   // HANDLE
  InfoType: Integer;   // DS_REPL_INFO_TYPE
  pszObject: PWideChar;   // LPCWSTR optional
  puuidForSourceDsaObjGuid: PGUID;   // GUID* optional
  pszAttributeName: PWideChar;   // LPCWSTR optional
  pszValue: PWideChar;   // LPCWSTR optional
  dwFlags: DWORD;   // DWORD
  dwEnumerationContext: DWORD;   // DWORD
  ppInfo: Pointer   // void** out
): DWORD; stdcall;
  external 'NTDSAPI.dll' name 'DsReplicaGetInfo2W';
result := DllCall("NTDSAPI\DsReplicaGetInfo2W"
    , "Ptr", hDS   ; HANDLE
    , "Int", InfoType   ; DS_REPL_INFO_TYPE
    , "WStr", pszObject   ; LPCWSTR optional
    , "Ptr", puuidForSourceDsaObjGuid   ; GUID* optional
    , "WStr", pszAttributeName   ; LPCWSTR optional
    , "WStr", pszValue   ; LPCWSTR optional
    , "UInt", dwFlags   ; DWORD
    , "UInt", dwEnumerationContext   ; DWORD
    , "Ptr", ppInfo   ; void** out
    , "UInt")   ; return: DWORD
●DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo) = DLL("NTDSAPI.dll", "dword DsReplicaGetInfo2W(void*, int, char*, void*, char*, char*, dword, dword, void*)")
# 呼び出し: DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, ppInfo)
# hDS : HANDLE -> "void*"
# InfoType : DS_REPL_INFO_TYPE -> "int"
# pszObject : LPCWSTR optional -> "char*"
# puuidForSourceDsaObjGuid : GUID* optional -> "void*"
# pszAttributeName : LPCWSTR optional -> "char*"
# pszValue : LPCWSTR optional -> "char*"
# dwFlags : DWORD -> "dword"
# dwEnumerationContext : DWORD -> "dword"
# ppInfo : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。