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