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