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