Win32 API 日本語リファレンス
ホームNetworkManagement.Dhcp › DhcpV4FailoverGetScopeRelationship

DhcpV4FailoverGetScopeRelationship

関数
指定スコープが属するIPv4フェールオーバー関係を取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4FailoverGetScopeRelationship(
    LPWSTR ServerIpAddress,   // optional
    DWORD ScopeId,
    DHCP_FAILOVER_RELATIONSHIP** pRelationship
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
ScopeIdDWORDin
pRelationshipDHCP_FAILOVER_RELATIONSHIP**out

戻り値の型: DWORD

各言語での呼び出し定義

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4FailoverGetScopeRelationship(
    LPWSTR ServerIpAddress,   // optional
    DWORD ScopeId,
    DHCP_FAILOVER_RELATIONSHIP** pRelationship
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpV4FailoverGetScopeRelationship(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPWSTR optional
    uint ScopeId,   // DWORD
    IntPtr pRelationship   // DHCP_FAILOVER_RELATIONSHIP** out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpV4FailoverGetScopeRelationship(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPWSTR optional
    ScopeId As UInteger,   ' DWORD
    pRelationship As IntPtr   ' DHCP_FAILOVER_RELATIONSHIP** out
) As UInteger
End Function
' ServerIpAddress : LPWSTR optional
' ScopeId : DWORD
' pRelationship : DHCP_FAILOVER_RELATIONSHIP** out
Declare PtrSafe Function DhcpV4FailoverGetScopeRelationship Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByVal ScopeId 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

DhcpV4FailoverGetScopeRelationship = ctypes.windll.dhcpsapi.DhcpV4FailoverGetScopeRelationship
DhcpV4FailoverGetScopeRelationship.restype = wintypes.DWORD
DhcpV4FailoverGetScopeRelationship.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.DWORD,  # ScopeId : DWORD
    ctypes.c_void_p,  # pRelationship : DHCP_FAILOVER_RELATIONSHIP** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpV4FailoverGetScopeRelationship = Fiddle::Function.new(
  lib['DhcpV4FailoverGetScopeRelationship'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    -Fiddle::TYPE_INT,  # ScopeId : DWORD
    Fiddle::TYPE_VOIDP,  # pRelationship : DHCP_FAILOVER_RELATIONSHIP** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpV4FailoverGetScopeRelationship(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        ScopeId: u32,  // DWORD
        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 DhcpV4FailoverGetScopeRelationship([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, uint ScopeId, IntPtr pRelationship);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpV4FailoverGetScopeRelationship' -Namespace Win32 -PassThru
# $api::DhcpV4FailoverGetScopeRelationship(ServerIpAddress, ScopeId, pRelationship)
#uselib "DHCPSAPI.dll"
#func global DhcpV4FailoverGetScopeRelationship "DhcpV4FailoverGetScopeRelationship" sptr, sptr, sptr
; DhcpV4FailoverGetScopeRelationship ServerIpAddress, ScopeId, varptr(pRelationship)   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; ScopeId : DWORD -> "sptr"
; pRelationship : DHCP_FAILOVER_RELATIONSHIP** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverGetScopeRelationship "DhcpV4FailoverGetScopeRelationship" wstr, int, var
; res = DhcpV4FailoverGetScopeRelationship(ServerIpAddress, ScopeId, pRelationship)
; ServerIpAddress : LPWSTR optional -> "wstr"
; ScopeId : DWORD -> "int"
; pRelationship : DHCP_FAILOVER_RELATIONSHIP** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DhcpV4FailoverGetScopeRelationship(LPWSTR ServerIpAddress, DWORD ScopeId, DHCP_FAILOVER_RELATIONSHIP** pRelationship)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverGetScopeRelationship "DhcpV4FailoverGetScopeRelationship" wstr, int, var
; res = DhcpV4FailoverGetScopeRelationship(ServerIpAddress, ScopeId, pRelationship)
; ServerIpAddress : LPWSTR optional -> "wstr"
; ScopeId : DWORD -> "int"
; pRelationship : DHCP_FAILOVER_RELATIONSHIP** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4FailoverGetScopeRelationship = dhcpsapi.NewProc("DhcpV4FailoverGetScopeRelationship")
)

// ServerIpAddress (LPWSTR optional), ScopeId (DWORD), pRelationship (DHCP_FAILOVER_RELATIONSHIP** out)
r1, _, err := procDhcpV4FailoverGetScopeRelationship.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(ScopeId),
	uintptr(pRelationship),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpV4FailoverGetScopeRelationship(
  ServerIpAddress: PWideChar;   // LPWSTR optional
  ScopeId: DWORD;   // DWORD
  pRelationship: Pointer   // DHCP_FAILOVER_RELATIONSHIP** out
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpV4FailoverGetScopeRelationship';
result := DllCall("DHCPSAPI\DhcpV4FailoverGetScopeRelationship"
    , "WStr", ServerIpAddress   ; LPWSTR optional
    , "UInt", ScopeId   ; DWORD
    , "Ptr", pRelationship   ; DHCP_FAILOVER_RELATIONSHIP** out
    , "UInt")   ; return: DWORD
●DhcpV4FailoverGetScopeRelationship(ServerIpAddress, ScopeId, pRelationship) = DLL("DHCPSAPI.dll", "dword DhcpV4FailoverGetScopeRelationship(char*, dword, void*)")
# 呼び出し: DhcpV4FailoverGetScopeRelationship(ServerIpAddress, ScopeId, pRelationship)
# ServerIpAddress : LPWSTR optional -> "char*"
# ScopeId : DWORD -> "dword"
# pRelationship : DHCP_FAILOVER_RELATIONSHIP** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。