ホーム › Networking.ActiveDirectory › DsReplicaAddW
DsReplicaAddW
関数複製元サーバーをレプリケーション構成に追加する(Unicode版)。
シグネチャ
// NTDSAPI.dll (Unicode / -W)
#include <windows.h>
DWORD DsReplicaAddW(
HANDLE hDS,
LPCWSTR NameContext,
LPCWSTR SourceDsaDn,
LPCWSTR TransportDn,
LPCWSTR SourceDsaAddress,
const SCHEDULE* pSchedule, // optional
DWORD Options
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDS | HANDLE | in | 操作に用いるディレクトリサービスバインドハンドル。 |
| NameContext | LPCWSTR | in | 複製対象の名前付けコンテキストのDN(ワイド)。 |
| SourceDsaDn | LPCWSTR | in | 複製元DSAのオブジェクトDN。 |
| TransportDn | LPCWSTR | in | サイト間トランスポートのDN。サイト内ではNULL。 |
| SourceDsaAddress | LPCWSTR | in | 複製元DSAのネットワークアドレス(GUIDベースのDNS名等)。 |
| pSchedule | SCHEDULE* | inoptional | 複製スケジュールを示すSCHEDULE構造体へのポインタ。NULL可。 |
| Options | DWORD | in | 複製リンクの動作を制御するDS_REPADD_*フラグ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// NTDSAPI.dll (Unicode / -W)
#include <windows.h>
DWORD DsReplicaAddW(
HANDLE hDS,
LPCWSTR NameContext,
LPCWSTR SourceDsaDn,
LPCWSTR TransportDn,
LPCWSTR SourceDsaAddress,
const SCHEDULE* pSchedule, // optional
DWORD Options
);[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsReplicaAddW(
IntPtr hDS, // HANDLE
[MarshalAs(UnmanagedType.LPWStr)] string NameContext, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string SourceDsaDn, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string TransportDn, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string SourceDsaAddress, // LPCWSTR
IntPtr pSchedule, // SCHEDULE* optional
uint Options // DWORD
);<DllImport("NTDSAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsReplicaAddW(
hDS As IntPtr, ' HANDLE
<MarshalAs(UnmanagedType.LPWStr)> NameContext As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> SourceDsaDn As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> TransportDn As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> SourceDsaAddress As String, ' LPCWSTR
pSchedule As IntPtr, ' SCHEDULE* optional
Options As UInteger ' DWORD
) As UInteger
End Function' hDS : HANDLE
' NameContext : LPCWSTR
' SourceDsaDn : LPCWSTR
' TransportDn : LPCWSTR
' SourceDsaAddress : LPCWSTR
' pSchedule : SCHEDULE* optional
' Options : DWORD
Declare PtrSafe Function DsReplicaAddW Lib "ntdsapi" ( _
ByVal hDS As LongPtr, _
ByVal NameContext As LongPtr, _
ByVal SourceDsaDn As LongPtr, _
ByVal TransportDn As LongPtr, _
ByVal SourceDsaAddress As LongPtr, _
ByVal pSchedule 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
DsReplicaAddW = ctypes.windll.ntdsapi.DsReplicaAddW
DsReplicaAddW.restype = wintypes.DWORD
DsReplicaAddW.argtypes = [
wintypes.HANDLE, # hDS : HANDLE
wintypes.LPCWSTR, # NameContext : LPCWSTR
wintypes.LPCWSTR, # SourceDsaDn : LPCWSTR
wintypes.LPCWSTR, # TransportDn : LPCWSTR
wintypes.LPCWSTR, # SourceDsaAddress : LPCWSTR
ctypes.c_void_p, # pSchedule : SCHEDULE* optional
wintypes.DWORD, # Options : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NTDSAPI.dll')
DsReplicaAddW = Fiddle::Function.new(
lib['DsReplicaAddW'],
[
Fiddle::TYPE_VOIDP, # hDS : HANDLE
Fiddle::TYPE_VOIDP, # NameContext : LPCWSTR
Fiddle::TYPE_VOIDP, # SourceDsaDn : LPCWSTR
Fiddle::TYPE_VOIDP, # TransportDn : LPCWSTR
Fiddle::TYPE_VOIDP, # SourceDsaAddress : LPCWSTR
Fiddle::TYPE_VOIDP, # pSchedule : SCHEDULE* optional
-Fiddle::TYPE_INT, # Options : DWORD
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "ntdsapi")]
extern "system" {
fn DsReplicaAddW(
hDS: *mut core::ffi::c_void, // HANDLE
NameContext: *const u16, // LPCWSTR
SourceDsaDn: *const u16, // LPCWSTR
TransportDn: *const u16, // LPCWSTR
SourceDsaAddress: *const u16, // LPCWSTR
pSchedule: *const SCHEDULE, // SCHEDULE* optional
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 DsReplicaAddW(IntPtr hDS, [MarshalAs(UnmanagedType.LPWStr)] string NameContext, [MarshalAs(UnmanagedType.LPWStr)] string SourceDsaDn, [MarshalAs(UnmanagedType.LPWStr)] string TransportDn, [MarshalAs(UnmanagedType.LPWStr)] string SourceDsaAddress, IntPtr pSchedule, uint Options);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsReplicaAddW' -Namespace Win32 -PassThru
# $api::DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)#uselib "NTDSAPI.dll"
#func global DsReplicaAddW "DsReplicaAddW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; DsReplicaAddW hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, varptr(pSchedule), Options ; 戻り値は stat
; hDS : HANDLE -> "wptr"
; NameContext : LPCWSTR -> "wptr"
; SourceDsaDn : LPCWSTR -> "wptr"
; TransportDn : LPCWSTR -> "wptr"
; SourceDsaAddress : LPCWSTR -> "wptr"
; pSchedule : SCHEDULE* optional -> "wptr"
; Options : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NTDSAPI.dll" #cfunc global DsReplicaAddW "DsReplicaAddW" sptr, wstr, wstr, wstr, wstr, var, int ; res = DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options) ; hDS : HANDLE -> "sptr" ; NameContext : LPCWSTR -> "wstr" ; SourceDsaDn : LPCWSTR -> "wstr" ; TransportDn : LPCWSTR -> "wstr" ; SourceDsaAddress : LPCWSTR -> "wstr" ; pSchedule : SCHEDULE* optional -> "var" ; Options : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NTDSAPI.dll" #cfunc global DsReplicaAddW "DsReplicaAddW" sptr, wstr, wstr, wstr, wstr, sptr, int ; res = DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, varptr(pSchedule), Options) ; hDS : HANDLE -> "sptr" ; NameContext : LPCWSTR -> "wstr" ; SourceDsaDn : LPCWSTR -> "wstr" ; TransportDn : LPCWSTR -> "wstr" ; SourceDsaAddress : LPCWSTR -> "wstr" ; pSchedule : SCHEDULE* optional -> "sptr" ; Options : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DsReplicaAddW(HANDLE hDS, LPCWSTR NameContext, LPCWSTR SourceDsaDn, LPCWSTR TransportDn, LPCWSTR SourceDsaAddress, SCHEDULE* pSchedule, DWORD Options) #uselib "NTDSAPI.dll" #cfunc global DsReplicaAddW "DsReplicaAddW" intptr, wstr, wstr, wstr, wstr, var, int ; res = DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options) ; hDS : HANDLE -> "intptr" ; NameContext : LPCWSTR -> "wstr" ; SourceDsaDn : LPCWSTR -> "wstr" ; TransportDn : LPCWSTR -> "wstr" ; SourceDsaAddress : LPCWSTR -> "wstr" ; pSchedule : SCHEDULE* optional -> "var" ; Options : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DsReplicaAddW(HANDLE hDS, LPCWSTR NameContext, LPCWSTR SourceDsaDn, LPCWSTR TransportDn, LPCWSTR SourceDsaAddress, SCHEDULE* pSchedule, DWORD Options) #uselib "NTDSAPI.dll" #cfunc global DsReplicaAddW "DsReplicaAddW" intptr, wstr, wstr, wstr, wstr, intptr, int ; res = DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, varptr(pSchedule), Options) ; hDS : HANDLE -> "intptr" ; NameContext : LPCWSTR -> "wstr" ; SourceDsaDn : LPCWSTR -> "wstr" ; TransportDn : LPCWSTR -> "wstr" ; SourceDsaAddress : LPCWSTR -> "wstr" ; pSchedule : SCHEDULE* optional -> "intptr" ; Options : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
procDsReplicaAddW = ntdsapi.NewProc("DsReplicaAddW")
)
// hDS (HANDLE), NameContext (LPCWSTR), SourceDsaDn (LPCWSTR), TransportDn (LPCWSTR), SourceDsaAddress (LPCWSTR), pSchedule (SCHEDULE* optional), Options (DWORD)
r1, _, err := procDsReplicaAddW.Call(
uintptr(hDS),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(NameContext))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceDsaDn))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TransportDn))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceDsaAddress))),
uintptr(pSchedule),
uintptr(Options),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DsReplicaAddW(
hDS: THandle; // HANDLE
NameContext: PWideChar; // LPCWSTR
SourceDsaDn: PWideChar; // LPCWSTR
TransportDn: PWideChar; // LPCWSTR
SourceDsaAddress: PWideChar; // LPCWSTR
pSchedule: Pointer; // SCHEDULE* optional
Options: DWORD // DWORD
): DWORD; stdcall;
external 'NTDSAPI.dll' name 'DsReplicaAddW';result := DllCall("NTDSAPI\DsReplicaAddW"
, "Ptr", hDS ; HANDLE
, "WStr", NameContext ; LPCWSTR
, "WStr", SourceDsaDn ; LPCWSTR
, "WStr", TransportDn ; LPCWSTR
, "WStr", SourceDsaAddress ; LPCWSTR
, "Ptr", pSchedule ; SCHEDULE* optional
, "UInt", Options ; DWORD
, "UInt") ; return: DWORD●DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options) = DLL("NTDSAPI.dll", "dword DsReplicaAddW(void*, char*, char*, char*, char*, void*, dword)")
# 呼び出し: DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)
# hDS : HANDLE -> "void*"
# NameContext : LPCWSTR -> "char*"
# SourceDsaDn : LPCWSTR -> "char*"
# TransportDn : LPCWSTR -> "char*"
# SourceDsaAddress : LPCWSTR -> "char*"
# pSchedule : SCHEDULE* optional -> "void*"
# Options : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "ntdsapi" fn DsReplicaAddW(
hDS: ?*anyopaque, // HANDLE
NameContext: [*c]const u16, // LPCWSTR
SourceDsaDn: [*c]const u16, // LPCWSTR
TransportDn: [*c]const u16, // LPCWSTR
SourceDsaAddress: [*c]const u16, // LPCWSTR
pSchedule: [*c]SCHEDULE, // SCHEDULE* optional
Options: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc DsReplicaAddW(
hDS: pointer, # HANDLE
NameContext: WideCString, # LPCWSTR
SourceDsaDn: WideCString, # LPCWSTR
TransportDn: WideCString, # LPCWSTR
SourceDsaAddress: WideCString, # LPCWSTR
pSchedule: ptr SCHEDULE, # SCHEDULE* optional
Options: uint32 # DWORD
): uint32 {.importc: "DsReplicaAddW", stdcall, dynlib: "NTDSAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "ntdsapi");
extern(Windows)
uint DsReplicaAddW(
void* hDS, // HANDLE
const(wchar)* NameContext, // LPCWSTR
const(wchar)* SourceDsaDn, // LPCWSTR
const(wchar)* TransportDn, // LPCWSTR
const(wchar)* SourceDsaAddress, // LPCWSTR
SCHEDULE* pSchedule, // SCHEDULE* optional
uint Options // DWORD
);ccall((:DsReplicaAddW, "NTDSAPI.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, Cwstring, Ptr{SCHEDULE}, UInt32),
hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)
# hDS : HANDLE -> Ptr{Cvoid}
# NameContext : LPCWSTR -> Cwstring
# SourceDsaDn : LPCWSTR -> Cwstring
# TransportDn : LPCWSTR -> Cwstring
# SourceDsaAddress : LPCWSTR -> Cwstring
# pSchedule : SCHEDULE* optional -> Ptr{SCHEDULE}
# Options : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t DsReplicaAddW(
void* hDS,
const uint16_t* NameContext,
const uint16_t* SourceDsaDn,
const uint16_t* TransportDn,
const uint16_t* SourceDsaAddress,
void* pSchedule,
uint32_t Options);
]]
local ntdsapi = ffi.load("ntdsapi")
-- ntdsapi.DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)
-- hDS : HANDLE
-- NameContext : LPCWSTR
-- SourceDsaDn : LPCWSTR
-- TransportDn : LPCWSTR
-- SourceDsaAddress : LPCWSTR
-- pSchedule : SCHEDULE* optional
-- Options : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('NTDSAPI.dll');
const DsReplicaAddW = lib.func('__stdcall', 'DsReplicaAddW', 'uint32_t', ['void *', 'str16', 'str16', 'str16', 'str16', 'void *', 'uint32_t']);
// DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)
// hDS : HANDLE -> 'void *'
// NameContext : LPCWSTR -> 'str16'
// SourceDsaDn : LPCWSTR -> 'str16'
// TransportDn : LPCWSTR -> 'str16'
// SourceDsaAddress : LPCWSTR -> 'str16'
// pSchedule : SCHEDULE* optional -> 'void *'
// Options : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NTDSAPI.dll", {
DsReplicaAddW: { parameters: ["pointer", "buffer", "buffer", "buffer", "buffer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options)
// hDS : HANDLE -> "pointer"
// NameContext : LPCWSTR -> "buffer"
// SourceDsaDn : LPCWSTR -> "buffer"
// TransportDn : LPCWSTR -> "buffer"
// SourceDsaAddress : LPCWSTR -> "buffer"
// pSchedule : SCHEDULE* optional -> "pointer"
// Options : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DsReplicaAddW(
void* hDS,
const uint16_t* NameContext,
const uint16_t* SourceDsaDn,
const uint16_t* TransportDn,
const uint16_t* SourceDsaAddress,
void* pSchedule,
uint32_t Options);
C, "NTDSAPI.dll");
// $ffi->DsReplicaAddW(hDS, NameContext, SourceDsaDn, TransportDn, SourceDsaAddress, pSchedule, Options);
// hDS : HANDLE
// NameContext : LPCWSTR
// SourceDsaDn : LPCWSTR
// TransportDn : LPCWSTR
// SourceDsaAddress : LPCWSTR
// pSchedule : SCHEDULE* optional
// Options : DWORD
// 構造体/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 Ntdsapi extends StdCallLibrary {
Ntdsapi INSTANCE = Native.load("ntdsapi", Ntdsapi.class, W32APIOptions.UNICODE_OPTIONS);
int DsReplicaAddW(
Pointer hDS, // HANDLE
WString NameContext, // LPCWSTR
WString SourceDsaDn, // LPCWSTR
WString TransportDn, // LPCWSTR
WString SourceDsaAddress, // LPCWSTR
Pointer pSchedule, // SCHEDULE* optional
int Options // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("ntdsapi")]
lib LibNTDSAPI
fun DsReplicaAddW = DsReplicaAddW(
hDS : Void*, # HANDLE
NameContext : UInt16*, # LPCWSTR
SourceDsaDn : UInt16*, # LPCWSTR
TransportDn : UInt16*, # LPCWSTR
SourceDsaAddress : UInt16*, # LPCWSTR
pSchedule : SCHEDULE*, # SCHEDULE* optional
Options : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DsReplicaAddWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Uint32);
typedef DsReplicaAddWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, int);
final DsReplicaAddW = DynamicLibrary.open('NTDSAPI.dll')
.lookupFunction<DsReplicaAddWNative, DsReplicaAddWDart>('DsReplicaAddW');
// hDS : HANDLE -> Pointer<Void>
// NameContext : LPCWSTR -> Pointer<Utf16>
// SourceDsaDn : LPCWSTR -> Pointer<Utf16>
// TransportDn : LPCWSTR -> Pointer<Utf16>
// SourceDsaAddress : LPCWSTR -> Pointer<Utf16>
// pSchedule : SCHEDULE* optional -> Pointer<Void>
// Options : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DsReplicaAddW(
hDS: THandle; // HANDLE
NameContext: PWideChar; // LPCWSTR
SourceDsaDn: PWideChar; // LPCWSTR
TransportDn: PWideChar; // LPCWSTR
SourceDsaAddress: PWideChar; // LPCWSTR
pSchedule: Pointer; // SCHEDULE* optional
Options: DWORD // DWORD
): DWORD; stdcall;
external 'NTDSAPI.dll' name 'DsReplicaAddW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DsReplicaAddW"
c_DsReplicaAddW :: Ptr () -> CWString -> CWString -> CWString -> CWString -> Ptr () -> Word32 -> IO Word32
-- hDS : HANDLE -> Ptr ()
-- NameContext : LPCWSTR -> CWString
-- SourceDsaDn : LPCWSTR -> CWString
-- TransportDn : LPCWSTR -> CWString
-- SourceDsaAddress : LPCWSTR -> CWString
-- pSchedule : SCHEDULE* optional -> Ptr ()
-- Options : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dsreplicaaddw =
foreign "DsReplicaAddW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> uint32_t @-> returning uint32_t)
(* hDS : HANDLE -> (ptr void) *)
(* NameContext : LPCWSTR -> (ptr uint16_t) *)
(* SourceDsaDn : LPCWSTR -> (ptr uint16_t) *)
(* TransportDn : LPCWSTR -> (ptr uint16_t) *)
(* SourceDsaAddress : LPCWSTR -> (ptr uint16_t) *)
(* pSchedule : SCHEDULE* optional -> (ptr void) *)
(* Options : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ntdsapi (t "NTDSAPI.dll"))
(cffi:use-foreign-library ntdsapi)
(cffi:defcfun ("DsReplicaAddW" ds-replica-add-w :convention :stdcall) :uint32
(h-ds :pointer) ; HANDLE
(name-context (:string :encoding :utf-16le)) ; LPCWSTR
(source-dsa-dn (:string :encoding :utf-16le)) ; LPCWSTR
(transport-dn (:string :encoding :utf-16le)) ; LPCWSTR
(source-dsa-address (:string :encoding :utf-16le)) ; LPCWSTR
(p-schedule :pointer) ; SCHEDULE* optional
(options :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DsReplicaAddW = Win32::API::More->new('NTDSAPI',
'DWORD DsReplicaAddW(HANDLE hDS, LPCWSTR NameContext, LPCWSTR SourceDsaDn, LPCWSTR TransportDn, LPCWSTR SourceDsaAddress, LPVOID pSchedule, DWORD Options)');
# my $ret = $DsReplicaAddW->Call($hDS, $NameContext, $SourceDsaDn, $TransportDn, $SourceDsaAddress, $pSchedule, $Options);
# hDS : HANDLE -> HANDLE
# NameContext : LPCWSTR -> LPCWSTR
# SourceDsaDn : LPCWSTR -> LPCWSTR
# TransportDn : LPCWSTR -> LPCWSTR
# SourceDsaAddress : LPCWSTR -> LPCWSTR
# pSchedule : SCHEDULE* optional -> LPVOID
# Options : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f DsReplicaAddA (ANSI版) — 複製元サーバーをレプリケーション構成に追加する(ANSI版)。
使用する型