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

DsDeregisterDnsHostRecordsW

関数
指定DCに関するDNSホストレコードの登録を解除する。
DLLNETAPI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD DsDeregisterDnsHostRecordsW(
    LPWSTR ServerName,   // optional
    LPWSTR DnsDomainName,   // optional
    GUID* DomainGuid,   // optional
    GUID* DsaGuid,   // optional
    LPWSTR DnsHostName
);

パラメーター

名前方向説明
ServerNameLPWSTRinoptional操作を実行するDNSサーバ/DC名を指すワイド文字列。ローカルの場合はNULL可。
DnsDomainNameLPWSTRinoptional登録解除対象のDNSドメイン名を指すワイド文字列。
DomainGuidGUID*inoptional対象ドメインのGUIDへのポインタ。GUIDベースのレコード削除用で不要ならNULL可。
DsaGuidGUID*inoptional対象DCのDSA GUIDへのポインタ。CNAMEレコード削除用で不要ならNULL可。
DnsHostNameLPWSTRin登録解除するDCのDNSホスト名を指すワイド文字列。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DsDeregisterDnsHostRecordsW(
    LPWSTR ServerName,   // optional
    LPWSTR DnsDomainName,   // optional
    GUID* DomainGuid,   // optional
    GUID* DsaGuid,   // optional
    LPWSTR DnsHostName
);
[DllImport("NETAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsDeregisterDnsHostRecordsW(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerName,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string DnsDomainName,   // LPWSTR optional
    IntPtr DomainGuid,   // GUID* optional
    IntPtr DsaGuid,   // GUID* optional
    [MarshalAs(UnmanagedType.LPWStr)] string DnsHostName   // LPWSTR
);
<DllImport("NETAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsDeregisterDnsHostRecordsW(
    <MarshalAs(UnmanagedType.LPWStr)> ServerName As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> DnsDomainName As String,   ' LPWSTR optional
    DomainGuid As IntPtr,   ' GUID* optional
    DsaGuid As IntPtr,   ' GUID* optional
    <MarshalAs(UnmanagedType.LPWStr)> DnsHostName As String   ' LPWSTR
) As UInteger
End Function
' ServerName : LPWSTR optional
' DnsDomainName : LPWSTR optional
' DomainGuid : GUID* optional
' DsaGuid : GUID* optional
' DnsHostName : LPWSTR
Declare PtrSafe Function DsDeregisterDnsHostRecordsW Lib "netapi32" ( _
    ByVal ServerName As LongPtr, _
    ByVal DnsDomainName As LongPtr, _
    ByVal DomainGuid As LongPtr, _
    ByVal DsaGuid As LongPtr, _
    ByVal DnsHostName 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

DsDeregisterDnsHostRecordsW = ctypes.windll.netapi32.DsDeregisterDnsHostRecordsW
DsDeregisterDnsHostRecordsW.restype = wintypes.DWORD
DsDeregisterDnsHostRecordsW.argtypes = [
    wintypes.LPCWSTR,  # ServerName : LPWSTR optional
    wintypes.LPCWSTR,  # DnsDomainName : LPWSTR optional
    ctypes.c_void_p,  # DomainGuid : GUID* optional
    ctypes.c_void_p,  # DsaGuid : GUID* optional
    wintypes.LPCWSTR,  # DnsHostName : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procDsDeregisterDnsHostRecordsW = netapi32.NewProc("DsDeregisterDnsHostRecordsW")
)

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