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

GetAnycastIpAddressTable

関数
エニーキャストIPアドレスの一覧テーブルを取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR GetAnycastIpAddressTable(
    ADDRESS_FAMILY Family,
    MIB_ANYCASTIPADDRESS_TABLE** Table
);

パラメーター

名前方向
FamilyADDRESS_FAMILYin
TableMIB_ANYCASTIPADDRESS_TABLE**out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR GetAnycastIpAddressTable(
    ADDRESS_FAMILY Family,
    MIB_ANYCASTIPADDRESS_TABLE** Table
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetAnycastIpAddressTable(
    ushort Family,   // ADDRESS_FAMILY
    IntPtr Table   // MIB_ANYCASTIPADDRESS_TABLE** out
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetAnycastIpAddressTable(
    Family As UShort,   ' ADDRESS_FAMILY
    Table As IntPtr   ' MIB_ANYCASTIPADDRESS_TABLE** out
) As UInteger
End Function
' Family : ADDRESS_FAMILY
' Table : MIB_ANYCASTIPADDRESS_TABLE** out
Declare PtrSafe Function GetAnycastIpAddressTable Lib "iphlpapi" ( _
    ByVal Family As Integer, _
    ByVal Table As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetAnycastIpAddressTable = ctypes.windll.iphlpapi.GetAnycastIpAddressTable
GetAnycastIpAddressTable.restype = wintypes.DWORD
GetAnycastIpAddressTable.argtypes = [
    ctypes.c_ushort,  # Family : ADDRESS_FAMILY
    ctypes.c_void_p,  # Table : MIB_ANYCASTIPADDRESS_TABLE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IPHLPAPI.dll')
GetAnycastIpAddressTable = Fiddle::Function.new(
  lib['GetAnycastIpAddressTable'],
  [
    -Fiddle::TYPE_SHORT,  # Family : ADDRESS_FAMILY
    Fiddle::TYPE_VOIDP,  # Table : MIB_ANYCASTIPADDRESS_TABLE** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "iphlpapi")]
extern "system" {
    fn GetAnycastIpAddressTable(
        Family: u16,  // ADDRESS_FAMILY
        Table: *mut *mut MIB_ANYCASTIPADDRESS_TABLE  // MIB_ANYCASTIPADDRESS_TABLE** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint GetAnycastIpAddressTable(ushort Family, IntPtr Table);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetAnycastIpAddressTable' -Namespace Win32 -PassThru
# $api::GetAnycastIpAddressTable(Family, Table)
#uselib "IPHLPAPI.dll"
#func global GetAnycastIpAddressTable "GetAnycastIpAddressTable" sptr, sptr
; GetAnycastIpAddressTable Family, varptr(Table)   ; 戻り値は stat
; Family : ADDRESS_FAMILY -> "sptr"
; Table : MIB_ANYCASTIPADDRESS_TABLE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IPHLPAPI.dll"
#cfunc global GetAnycastIpAddressTable "GetAnycastIpAddressTable" int, var
; res = GetAnycastIpAddressTable(Family, Table)
; Family : ADDRESS_FAMILY -> "int"
; Table : MIB_ANYCASTIPADDRESS_TABLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR GetAnycastIpAddressTable(ADDRESS_FAMILY Family, MIB_ANYCASTIPADDRESS_TABLE** Table)
#uselib "IPHLPAPI.dll"
#cfunc global GetAnycastIpAddressTable "GetAnycastIpAddressTable" int, var
; res = GetAnycastIpAddressTable(Family, Table)
; Family : ADDRESS_FAMILY -> "int"
; Table : MIB_ANYCASTIPADDRESS_TABLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procGetAnycastIpAddressTable = iphlpapi.NewProc("GetAnycastIpAddressTable")
)

// Family (ADDRESS_FAMILY), Table (MIB_ANYCASTIPADDRESS_TABLE** out)
r1, _, err := procGetAnycastIpAddressTable.Call(
	uintptr(Family),
	uintptr(Table),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function GetAnycastIpAddressTable(
  Family: Word;   // ADDRESS_FAMILY
  Table: Pointer   // MIB_ANYCASTIPADDRESS_TABLE** out
): DWORD; stdcall;
  external 'IPHLPAPI.dll' name 'GetAnycastIpAddressTable';
result := DllCall("IPHLPAPI\GetAnycastIpAddressTable"
    , "UShort", Family   ; ADDRESS_FAMILY
    , "Ptr", Table   ; MIB_ANYCASTIPADDRESS_TABLE** out
    , "UInt")   ; return: WIN32_ERROR
●GetAnycastIpAddressTable(Family, Table) = DLL("IPHLPAPI.dll", "dword GetAnycastIpAddressTable(int, void*)")
# 呼び出し: GetAnycastIpAddressTable(Family, Table)
# Family : ADDRESS_FAMILY -> "int"
# Table : MIB_ANYCASTIPADDRESS_TABLE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。