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