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

DsBindToISTGW

関数
指定サイトのISTGサーバーへ接続する(Unicode版)。
DLLNTDSAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD DsBindToISTGW(
    LPCWSTR SiteName,   // optional
    HANDLE* phDS
);

パラメーター

名前方向
SiteNameLPCWSTRinoptional
phDSHANDLE*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DsBindToISTGW(
    LPCWSTR SiteName,   // optional
    HANDLE* phDS
);
[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsBindToISTGW(
    [MarshalAs(UnmanagedType.LPWStr)] string SiteName,   // LPCWSTR optional
    IntPtr phDS   // HANDLE* out
);
<DllImport("NTDSAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsBindToISTGW(
    <MarshalAs(UnmanagedType.LPWStr)> SiteName As String,   ' LPCWSTR optional
    phDS As IntPtr   ' HANDLE* out
) As UInteger
End Function
' SiteName : LPCWSTR optional
' phDS : HANDLE* out
Declare PtrSafe Function DsBindToISTGW Lib "ntdsapi" ( _
    ByVal SiteName As LongPtr, _
    ByVal phDS As LongPtr) 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

DsBindToISTGW = ctypes.windll.ntdsapi.DsBindToISTGW
DsBindToISTGW.restype = wintypes.DWORD
DsBindToISTGW.argtypes = [
    wintypes.LPCWSTR,  # SiteName : LPCWSTR optional
    ctypes.c_void_p,  # phDS : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NTDSAPI.dll')
DsBindToISTGW = Fiddle::Function.new(
  lib['DsBindToISTGW'],
  [
    Fiddle::TYPE_VOIDP,  # SiteName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # phDS : HANDLE* out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "ntdsapi")]
extern "system" {
    fn DsBindToISTGW(
        SiteName: *const u16,  // LPCWSTR optional
        phDS: *mut *mut core::ffi::c_void  // HANDLE* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NTDSAPI.dll", CharSet = CharSet.Unicode)]
public static extern uint DsBindToISTGW([MarshalAs(UnmanagedType.LPWStr)] string SiteName, IntPtr phDS);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsBindToISTGW' -Namespace Win32 -PassThru
# $api::DsBindToISTGW(SiteName, phDS)
#uselib "NTDSAPI.dll"
#func global DsBindToISTGW "DsBindToISTGW" wptr, wptr
; DsBindToISTGW SiteName, phDS   ; 戻り値は stat
; SiteName : LPCWSTR optional -> "wptr"
; phDS : HANDLE* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NTDSAPI.dll"
#cfunc global DsBindToISTGW "DsBindToISTGW" wstr, sptr
; res = DsBindToISTGW(SiteName, phDS)
; SiteName : LPCWSTR optional -> "wstr"
; phDS : HANDLE* out -> "sptr"
; DWORD DsBindToISTGW(LPCWSTR SiteName, HANDLE* phDS)
#uselib "NTDSAPI.dll"
#cfunc global DsBindToISTGW "DsBindToISTGW" wstr, intptr
; res = DsBindToISTGW(SiteName, phDS)
; SiteName : LPCWSTR optional -> "wstr"
; phDS : HANDLE* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
	procDsBindToISTGW = ntdsapi.NewProc("DsBindToISTGW")
)

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