ホーム › NetworkManagement.Dhcp › DhcpV4FailoverCreateRelationship
DhcpV4FailoverCreateRelationship
関数DHCPサーバー間のIPv4フェールオーバー関係を新規作成する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpV4FailoverCreateRelationship(
LPWSTR ServerIpAddress, // optional
DHCP_FAILOVER_RELATIONSHIP* pRelationship
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerIpAddress | LPWSTR | inoptional |
| pRelationship | DHCP_FAILOVER_RELATIONSHIP* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpV4FailoverCreateRelationship(
LPWSTR ServerIpAddress, // optional
DHCP_FAILOVER_RELATIONSHIP* pRelationship
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpV4FailoverCreateRelationship(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPWSTR optional
IntPtr pRelationship // DHCP_FAILOVER_RELATIONSHIP*
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpV4FailoverCreateRelationship(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPWSTR optional
pRelationship As IntPtr ' DHCP_FAILOVER_RELATIONSHIP*
) As UInteger
End Function' ServerIpAddress : LPWSTR optional
' pRelationship : DHCP_FAILOVER_RELATIONSHIP*
Declare PtrSafe Function DhcpV4FailoverCreateRelationship Lib "dhcpsapi" ( _
ByVal ServerIpAddress As LongPtr, _
ByVal pRelationship As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpV4FailoverCreateRelationship = ctypes.windll.dhcpsapi.DhcpV4FailoverCreateRelationship
DhcpV4FailoverCreateRelationship.restype = wintypes.DWORD
DhcpV4FailoverCreateRelationship.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPWSTR optional
ctypes.c_void_p, # pRelationship : DHCP_FAILOVER_RELATIONSHIP*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpV4FailoverCreateRelationship = Fiddle::Function.new(
lib['DhcpV4FailoverCreateRelationship'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPWSTR optional
Fiddle::TYPE_VOIDP, # pRelationship : DHCP_FAILOVER_RELATIONSHIP*
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpV4FailoverCreateRelationship(
ServerIpAddress: *mut u16, // LPWSTR optional
pRelationship: *mut DHCP_FAILOVER_RELATIONSHIP // DHCP_FAILOVER_RELATIONSHIP*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpV4FailoverCreateRelationship([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr pRelationship);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpV4FailoverCreateRelationship' -Namespace Win32 -PassThru
# $api::DhcpV4FailoverCreateRelationship(ServerIpAddress, pRelationship)#uselib "DHCPSAPI.dll"
#func global DhcpV4FailoverCreateRelationship "DhcpV4FailoverCreateRelationship" sptr, sptr
; DhcpV4FailoverCreateRelationship ServerIpAddress, varptr(pRelationship) ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpV4FailoverCreateRelationship "DhcpV4FailoverCreateRelationship" wstr, var ; res = DhcpV4FailoverCreateRelationship(ServerIpAddress, pRelationship) ; ServerIpAddress : LPWSTR optional -> "wstr" ; pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpV4FailoverCreateRelationship "DhcpV4FailoverCreateRelationship" wstr, sptr ; res = DhcpV4FailoverCreateRelationship(ServerIpAddress, varptr(pRelationship)) ; ServerIpAddress : LPWSTR optional -> "wstr" ; pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DhcpV4FailoverCreateRelationship(LPWSTR ServerIpAddress, DHCP_FAILOVER_RELATIONSHIP* pRelationship) #uselib "DHCPSAPI.dll" #cfunc global DhcpV4FailoverCreateRelationship "DhcpV4FailoverCreateRelationship" wstr, var ; res = DhcpV4FailoverCreateRelationship(ServerIpAddress, pRelationship) ; ServerIpAddress : LPWSTR optional -> "wstr" ; pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DhcpV4FailoverCreateRelationship(LPWSTR ServerIpAddress, DHCP_FAILOVER_RELATIONSHIP* pRelationship) #uselib "DHCPSAPI.dll" #cfunc global DhcpV4FailoverCreateRelationship "DhcpV4FailoverCreateRelationship" wstr, intptr ; res = DhcpV4FailoverCreateRelationship(ServerIpAddress, varptr(pRelationship)) ; ServerIpAddress : LPWSTR optional -> "wstr" ; pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpV4FailoverCreateRelationship = dhcpsapi.NewProc("DhcpV4FailoverCreateRelationship")
)
// ServerIpAddress (LPWSTR optional), pRelationship (DHCP_FAILOVER_RELATIONSHIP*)
r1, _, err := procDhcpV4FailoverCreateRelationship.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(pRelationship),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpV4FailoverCreateRelationship(
ServerIpAddress: PWideChar; // LPWSTR optional
pRelationship: Pointer // DHCP_FAILOVER_RELATIONSHIP*
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpV4FailoverCreateRelationship';result := DllCall("DHCPSAPI\DhcpV4FailoverCreateRelationship"
, "WStr", ServerIpAddress ; LPWSTR optional
, "Ptr", pRelationship ; DHCP_FAILOVER_RELATIONSHIP*
, "UInt") ; return: DWORD●DhcpV4FailoverCreateRelationship(ServerIpAddress, pRelationship) = DLL("DHCPSAPI.dll", "dword DhcpV4FailoverCreateRelationship(char*, void*)")
# 呼び出し: DhcpV4FailoverCreateRelationship(ServerIpAddress, pRelationship)
# ServerIpAddress : LPWSTR optional -> "char*"
# pRelationship : DHCP_FAILOVER_RELATIONSHIP* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。