ホーム › NetworkManagement.Dhcp › DhcpServerSetDnsRegCredentialsV5
DhcpServerSetDnsRegCredentialsV5
関数DHCPサーバーのDNS登録用資格情報をV5拡張で設定する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerSetDnsRegCredentialsV5(
LPWSTR ServerIpAddress, // optional
LPWSTR Uname, // optional
LPWSTR Domain, // optional
LPWSTR Passwd // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPWSTR | inoptional | 対象DHCPサーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。 |
| Uname | LPWSTR | inoptional | DNS動的登録に使うユーザー名文字列。 |
| Domain | LPWSTR | inoptional | DNS動的登録に使うドメイン名文字列。 |
| Passwd | LPWSTR | inoptional | DNS動的登録に使うパスワード文字列。 |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerSetDnsRegCredentialsV5(
LPWSTR ServerIpAddress, // optional
LPWSTR Uname, // optional
LPWSTR Domain, // optional
LPWSTR Passwd // optional
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpServerSetDnsRegCredentialsV5(
[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 DhcpServerSetDnsRegCredentialsV5(
<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 DhcpServerSetDnsRegCredentialsV5 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
DhcpServerSetDnsRegCredentialsV5 = ctypes.windll.dhcpsapi.DhcpServerSetDnsRegCredentialsV5
DhcpServerSetDnsRegCredentialsV5.restype = wintypes.DWORD
DhcpServerSetDnsRegCredentialsV5.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')
DhcpServerSetDnsRegCredentialsV5 = Fiddle::Function.new(
lib['DhcpServerSetDnsRegCredentialsV5'],
[
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 DhcpServerSetDnsRegCredentialsV5(
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 DhcpServerSetDnsRegCredentialsV5([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_DhcpServerSetDnsRegCredentialsV5' -Namespace Win32 -PassThru
# $api::DhcpServerSetDnsRegCredentialsV5(ServerIpAddress, Uname, Domain, Passwd)#uselib "DHCPSAPI.dll"
#func global DhcpServerSetDnsRegCredentialsV5 "DhcpServerSetDnsRegCredentialsV5" sptr, sptr, sptr, sptr
; DhcpServerSetDnsRegCredentialsV5 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 DhcpServerSetDnsRegCredentialsV5 "DhcpServerSetDnsRegCredentialsV5" wstr, wstr, wstr, wstr
; res = DhcpServerSetDnsRegCredentialsV5(ServerIpAddress, Uname, Domain, Passwd)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Uname : LPWSTR optional -> "wstr"
; Domain : LPWSTR optional -> "wstr"
; Passwd : LPWSTR optional -> "wstr"; DWORD DhcpServerSetDnsRegCredentialsV5(LPWSTR ServerIpAddress, LPWSTR Uname, LPWSTR Domain, LPWSTR Passwd)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpServerSetDnsRegCredentialsV5 "DhcpServerSetDnsRegCredentialsV5" wstr, wstr, wstr, wstr
; res = DhcpServerSetDnsRegCredentialsV5(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")
procDhcpServerSetDnsRegCredentialsV5 = dhcpsapi.NewProc("DhcpServerSetDnsRegCredentialsV5")
)
// ServerIpAddress (LPWSTR optional), Uname (LPWSTR optional), Domain (LPWSTR optional), Passwd (LPWSTR optional)
r1, _, err := procDhcpServerSetDnsRegCredentialsV5.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 // DWORDfunction DhcpServerSetDnsRegCredentialsV5(
ServerIpAddress: PWideChar; // LPWSTR optional
Uname: PWideChar; // LPWSTR optional
Domain: PWideChar; // LPWSTR optional
Passwd: PWideChar // LPWSTR optional
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpServerSetDnsRegCredentialsV5';result := DllCall("DHCPSAPI\DhcpServerSetDnsRegCredentialsV5"
, "WStr", ServerIpAddress ; LPWSTR optional
, "WStr", Uname ; LPWSTR optional
, "WStr", Domain ; LPWSTR optional
, "WStr", Passwd ; LPWSTR optional
, "UInt") ; return: DWORD●DhcpServerSetDnsRegCredentialsV5(ServerIpAddress, Uname, Domain, Passwd) = DLL("DHCPSAPI.dll", "dword DhcpServerSetDnsRegCredentialsV5(char*, char*, char*, char*)")
# 呼び出し: DhcpServerSetDnsRegCredentialsV5(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)。