Win32 API 日本語リファレンス
ホームNetworkManagement.Dhcp › DhcpServerSetDnsRegCredentials

DhcpServerSetDnsRegCredentials

関数
DHCPサーバーのDNS登録用資格情報を設定する。
DLLDHCPSAPI.dll呼出規約winapi

シグネチャ

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpServerSetDnsRegCredentials(
    LPWSTR ServerIpAddress,   // optional
    LPWSTR Uname,   // optional
    LPWSTR Domain,   // optional
    LPWSTR Passwd   // optional
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
UnameLPWSTRinoptional
DomainLPWSTRinoptional
PasswdLPWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpServerSetDnsRegCredentials(
    LPWSTR ServerIpAddress,   // optional
    LPWSTR Uname,   // optional
    LPWSTR Domain,   // optional
    LPWSTR Passwd   // optional
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpServerSetDnsRegCredentials(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string Uname,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string Domain,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string Passwd   // LPWSTR optional
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpServerSetDnsRegCredentials(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> Uname As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> Domain As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> Passwd As String   ' LPWSTR optional
) As UInteger
End Function
' ServerIpAddress : LPWSTR optional
' Uname : LPWSTR optional
' Domain : LPWSTR optional
' Passwd : LPWSTR optional
Declare PtrSafe Function DhcpServerSetDnsRegCredentials Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByVal Uname As LongPtr, _
    ByVal Domain As LongPtr, _
    ByVal Passwd As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpServerSetDnsRegCredentials = ctypes.windll.dhcpsapi.DhcpServerSetDnsRegCredentials
DhcpServerSetDnsRegCredentials.restype = wintypes.DWORD
DhcpServerSetDnsRegCredentials.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.LPCWSTR,  # Uname : LPWSTR optional
    wintypes.LPCWSTR,  # Domain : LPWSTR optional
    wintypes.LPCWSTR,  # Passwd : LPWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpServerSetDnsRegCredentials = Fiddle::Function.new(
  lib['DhcpServerSetDnsRegCredentials'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # Uname : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # Domain : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # Passwd : LPWSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpServerSetDnsRegCredentials(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        Uname: *mut u16,  // LPWSTR optional
        Domain: *mut u16,  // LPWSTR optional
        Passwd: *mut u16  // LPWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpServerSetDnsRegCredentials([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, [MarshalAs(UnmanagedType.LPWStr)] string Uname, [MarshalAs(UnmanagedType.LPWStr)] string Domain, [MarshalAs(UnmanagedType.LPWStr)] string Passwd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpServerSetDnsRegCredentials' -Namespace Win32 -PassThru
# $api::DhcpServerSetDnsRegCredentials(ServerIpAddress, Uname, Domain, Passwd)
#uselib "DHCPSAPI.dll"
#func global DhcpServerSetDnsRegCredentials "DhcpServerSetDnsRegCredentials" sptr, sptr, sptr, sptr
; DhcpServerSetDnsRegCredentials ServerIpAddress, Uname, Domain, Passwd   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; Uname : LPWSTR optional -> "sptr"
; Domain : LPWSTR optional -> "sptr"
; Passwd : LPWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "DHCPSAPI.dll"
#cfunc global DhcpServerSetDnsRegCredentials "DhcpServerSetDnsRegCredentials" wstr, wstr, wstr, wstr
; res = DhcpServerSetDnsRegCredentials(ServerIpAddress, Uname, Domain, Passwd)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Uname : LPWSTR optional -> "wstr"
; Domain : LPWSTR optional -> "wstr"
; Passwd : LPWSTR optional -> "wstr"
; DWORD DhcpServerSetDnsRegCredentials(LPWSTR ServerIpAddress, LPWSTR Uname, LPWSTR Domain, LPWSTR Passwd)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpServerSetDnsRegCredentials "DhcpServerSetDnsRegCredentials" wstr, wstr, wstr, wstr
; res = DhcpServerSetDnsRegCredentials(ServerIpAddress, Uname, Domain, Passwd)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Uname : LPWSTR optional -> "wstr"
; Domain : LPWSTR optional -> "wstr"
; Passwd : LPWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpServerSetDnsRegCredentials = dhcpsapi.NewProc("DhcpServerSetDnsRegCredentials")
)

// ServerIpAddress (LPWSTR optional), Uname (LPWSTR optional), Domain (LPWSTR optional), Passwd (LPWSTR optional)
r1, _, err := procDhcpServerSetDnsRegCredentials.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Uname))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Domain))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Passwd))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpServerSetDnsRegCredentials(
  ServerIpAddress: PWideChar;   // LPWSTR optional
  Uname: PWideChar;   // LPWSTR optional
  Domain: PWideChar;   // LPWSTR optional
  Passwd: PWideChar   // LPWSTR optional
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpServerSetDnsRegCredentials';
result := DllCall("DHCPSAPI\DhcpServerSetDnsRegCredentials"
    , "WStr", ServerIpAddress   ; LPWSTR optional
    , "WStr", Uname   ; LPWSTR optional
    , "WStr", Domain   ; LPWSTR optional
    , "WStr", Passwd   ; LPWSTR optional
    , "UInt")   ; return: DWORD
●DhcpServerSetDnsRegCredentials(ServerIpAddress, Uname, Domain, Passwd) = DLL("DHCPSAPI.dll", "dword DhcpServerSetDnsRegCredentials(char*, char*, char*, char*)")
# 呼び出し: DhcpServerSetDnsRegCredentials(ServerIpAddress, Uname, Domain, Passwd)
# ServerIpAddress : LPWSTR optional -> "char*"
# Uname : LPWSTR optional -> "char*"
# Domain : LPWSTR optional -> "char*"
# Passwd : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。