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

DsDeregisterDnsHostRecordsA

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

シグネチャ

// NETAPI32.dll  (ANSI / -A)
#include <windows.h>

DWORD DsDeregisterDnsHostRecordsA(
    LPSTR ServerName,   // optional
    LPSTR DnsDomainName,   // optional
    GUID* DomainGuid,   // optional
    GUID* DsaGuid,   // optional
    LPSTR DnsHostName
);

パラメーター

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

戻り値の型: DWORD

各言語での呼び出し定義

// NETAPI32.dll  (ANSI / -A)
#include <windows.h>

DWORD DsDeregisterDnsHostRecordsA(
    LPSTR ServerName,   // optional
    LPSTR DnsDomainName,   // optional
    GUID* DomainGuid,   // optional
    GUID* DsaGuid,   // optional
    LPSTR DnsHostName
);
[DllImport("NETAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint DsDeregisterDnsHostRecordsA(
    [MarshalAs(UnmanagedType.LPStr)] string ServerName,   // LPSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string DnsDomainName,   // LPSTR optional
    IntPtr DomainGuid,   // GUID* optional
    IntPtr DsaGuid,   // GUID* optional
    [MarshalAs(UnmanagedType.LPStr)] string DnsHostName   // LPSTR
);
<DllImport("NETAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function DsDeregisterDnsHostRecordsA(
    <MarshalAs(UnmanagedType.LPStr)> ServerName As String,   ' LPSTR optional
    <MarshalAs(UnmanagedType.LPStr)> DnsDomainName As String,   ' LPSTR optional
    DomainGuid As IntPtr,   ' GUID* optional
    DsaGuid As IntPtr,   ' GUID* optional
    <MarshalAs(UnmanagedType.LPStr)> DnsHostName As String   ' LPSTR
) As UInteger
End Function
' ServerName : LPSTR optional
' DnsDomainName : LPSTR optional
' DomainGuid : GUID* optional
' DsaGuid : GUID* optional
' DnsHostName : LPSTR
Declare PtrSafe Function DsDeregisterDnsHostRecordsA Lib "netapi32" ( _
    ByVal ServerName As String, _
    ByVal DnsDomainName As String, _
    ByVal DomainGuid As LongPtr, _
    ByVal DsaGuid As LongPtr, _
    ByVal DnsHostName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procDsDeregisterDnsHostRecordsA = netapi32.NewProc("DsDeregisterDnsHostRecordsA")
)

// ServerName (LPSTR optional), DnsDomainName (LPSTR optional), DomainGuid (GUID* optional), DsaGuid (GUID* optional), DnsHostName (LPSTR)
r1, _, err := procDsDeregisterDnsHostRecordsA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ServerName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DnsDomainName))),
	uintptr(DomainGuid),
	uintptr(DsaGuid),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DnsHostName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsDeregisterDnsHostRecordsA(
  ServerName: PAnsiChar;   // LPSTR optional
  DnsDomainName: PAnsiChar;   // LPSTR optional
  DomainGuid: PGUID;   // GUID* optional
  DsaGuid: PGUID;   // GUID* optional
  DnsHostName: PAnsiChar   // LPSTR
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'DsDeregisterDnsHostRecordsA';
result := DllCall("NETAPI32\DsDeregisterDnsHostRecordsA"
    , "AStr", ServerName   ; LPSTR optional
    , "AStr", DnsDomainName   ; LPSTR optional
    , "Ptr", DomainGuid   ; GUID* optional
    , "Ptr", DsaGuid   ; GUID* optional
    , "AStr", DnsHostName   ; LPSTR
    , "UInt")   ; return: DWORD
●DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName) = DLL("NETAPI32.dll", "dword DsDeregisterDnsHostRecordsA(char*, char*, void*, void*, char*)")
# 呼び出し: DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName)
# ServerName : LPSTR optional -> "char*"
# DnsDomainName : LPSTR optional -> "char*"
# DomainGuid : GUID* optional -> "void*"
# DsaGuid : GUID* optional -> "void*"
# DnsHostName : LPSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "netapi32" fn DsDeregisterDnsHostRecordsA(
    ServerName: [*c]const u8, // LPSTR optional
    DnsDomainName: [*c]const u8, // LPSTR optional
    DomainGuid: [*c]GUID, // GUID* optional
    DsaGuid: [*c]GUID, // GUID* optional
    DnsHostName: [*c]const u8 // LPSTR
) callconv(std.os.windows.WINAPI) u32;
proc DsDeregisterDnsHostRecordsA(
    ServerName: cstring,  # LPSTR optional
    DnsDomainName: cstring,  # LPSTR optional
    DomainGuid: ptr GUID,  # GUID* optional
    DsaGuid: ptr GUID,  # GUID* optional
    DnsHostName: cstring  # LPSTR
): uint32 {.importc: "DsDeregisterDnsHostRecordsA", stdcall, dynlib: "NETAPI32.dll".}
pragma(lib, "netapi32");
extern(Windows)
uint DsDeregisterDnsHostRecordsA(
    const(char)* ServerName,   // LPSTR optional
    const(char)* DnsDomainName,   // LPSTR optional
    GUID* DomainGuid,   // GUID* optional
    GUID* DsaGuid,   // GUID* optional
    const(char)* DnsHostName   // LPSTR
);
ccall((:DsDeregisterDnsHostRecordsA, "NETAPI32.dll"), stdcall, UInt32,
      (Cstring, Cstring, Ptr{GUID}, Ptr{GUID}, Cstring),
      ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName)
# ServerName : LPSTR optional -> Cstring
# DnsDomainName : LPSTR optional -> Cstring
# DomainGuid : GUID* optional -> Ptr{GUID}
# DsaGuid : GUID* optional -> Ptr{GUID}
# DnsHostName : LPSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t DsDeregisterDnsHostRecordsA(
    const char* ServerName,
    const char* DnsDomainName,
    void* DomainGuid,
    void* DsaGuid,
    const char* DnsHostName);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName)
-- ServerName : LPSTR optional
-- DnsDomainName : LPSTR optional
-- DomainGuid : GUID* optional
-- DsaGuid : GUID* optional
-- DnsHostName : LPSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const DsDeregisterDnsHostRecordsA = lib.func('__stdcall', 'DsDeregisterDnsHostRecordsA', 'uint32_t', ['str', 'str', 'void *', 'void *', 'str']);
// DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName)
// ServerName : LPSTR optional -> 'str'
// DnsDomainName : LPSTR optional -> 'str'
// DomainGuid : GUID* optional -> 'void *'
// DsaGuid : GUID* optional -> 'void *'
// DnsHostName : LPSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("NETAPI32.dll", {
  DsDeregisterDnsHostRecordsA: { parameters: ["buffer", "buffer", "pointer", "pointer", "buffer"], result: "u32" },
});
// lib.symbols.DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName)
// ServerName : LPSTR optional -> "buffer"
// DnsDomainName : LPSTR optional -> "buffer"
// DomainGuid : GUID* optional -> "pointer"
// DsaGuid : GUID* optional -> "pointer"
// DnsHostName : LPSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t DsDeregisterDnsHostRecordsA(
    const char* ServerName,
    const char* DnsDomainName,
    void* DomainGuid,
    void* DsaGuid,
    const char* DnsHostName);
C, "NETAPI32.dll");
// $ffi->DsDeregisterDnsHostRecordsA(ServerName, DnsDomainName, DomainGuid, DsaGuid, DnsHostName);
// ServerName : LPSTR optional
// DnsDomainName : LPSTR optional
// DomainGuid : GUID* optional
// DsaGuid : GUID* optional
// DnsHostName : LPSTR
// 構造体/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 Netapi32 extends StdCallLibrary {
    Netapi32 INSTANCE = Native.load("netapi32", Netapi32.class, W32APIOptions.ASCII_OPTIONS);
    int DsDeregisterDnsHostRecordsA(
        String ServerName,   // LPSTR optional
        String DnsDomainName,   // LPSTR optional
        Pointer DomainGuid,   // GUID* optional
        Pointer DsaGuid,   // GUID* optional
        String DnsHostName   // LPSTR
    );
}
@[Link("netapi32")]
lib LibNETAPI32
  fun DsDeregisterDnsHostRecordsA = DsDeregisterDnsHostRecordsA(
    ServerName : UInt8*,   # LPSTR optional
    DnsDomainName : UInt8*,   # LPSTR optional
    DomainGuid : GUID*,   # GUID* optional
    DsaGuid : GUID*,   # GUID* optional
    DnsHostName : UInt8*   # LPSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DsDeregisterDnsHostRecordsANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
typedef DsDeregisterDnsHostRecordsADart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
final DsDeregisterDnsHostRecordsA = DynamicLibrary.open('NETAPI32.dll')
    .lookupFunction<DsDeregisterDnsHostRecordsANative, DsDeregisterDnsHostRecordsADart>('DsDeregisterDnsHostRecordsA');
// ServerName : LPSTR optional -> Pointer<Utf8>
// DnsDomainName : LPSTR optional -> Pointer<Utf8>
// DomainGuid : GUID* optional -> Pointer<Void>
// DsaGuid : GUID* optional -> Pointer<Void>
// DnsHostName : LPSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DsDeregisterDnsHostRecordsA(
  ServerName: PAnsiChar;   // LPSTR optional
  DnsDomainName: PAnsiChar;   // LPSTR optional
  DomainGuid: PGUID;   // GUID* optional
  DsaGuid: PGUID;   // GUID* optional
  DnsHostName: PAnsiChar   // LPSTR
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'DsDeregisterDnsHostRecordsA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DsDeregisterDnsHostRecordsA"
  c_DsDeregisterDnsHostRecordsA :: CString -> CString -> Ptr () -> Ptr () -> CString -> IO Word32
-- ServerName : LPSTR optional -> CString
-- DnsDomainName : LPSTR optional -> CString
-- DomainGuid : GUID* optional -> Ptr ()
-- DsaGuid : GUID* optional -> Ptr ()
-- DnsHostName : LPSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dsderegisterdnshostrecordsa =
  foreign "DsDeregisterDnsHostRecordsA"
    (string @-> string @-> (ptr void) @-> (ptr void) @-> string @-> returning uint32_t)
(* ServerName : LPSTR optional -> string *)
(* DnsDomainName : LPSTR optional -> string *)
(* DomainGuid : GUID* optional -> (ptr void) *)
(* DsaGuid : GUID* optional -> (ptr void) *)
(* DnsHostName : LPSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)

(cffi:defcfun ("DsDeregisterDnsHostRecordsA" ds-deregister-dns-host-records-a :convention :stdcall) :uint32
  (server-name :string)   ; LPSTR optional
  (dns-domain-name :string)   ; LPSTR optional
  (domain-guid :pointer)   ; GUID* optional
  (dsa-guid :pointer)   ; GUID* optional
  (dns-host-name :string))   ; LPSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DsDeregisterDnsHostRecordsA = Win32::API::More->new('NETAPI32',
    'DWORD DsDeregisterDnsHostRecordsA(LPCSTR ServerName, LPCSTR DnsDomainName, LPVOID DomainGuid, LPVOID DsaGuid, LPCSTR DnsHostName)');
# my $ret = $DsDeregisterDnsHostRecordsA->Call($ServerName, $DnsDomainName, $DomainGuid, $DsaGuid, $DnsHostName);
# ServerName : LPSTR optional -> LPCSTR
# DnsDomainName : LPSTR optional -> LPCSTR
# DomainGuid : GUID* optional -> LPVOID
# DsaGuid : GUID* optional -> LPVOID
# DnsHostName : LPSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い