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