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

GetIpNetTable

関数
IPv4アドレスと物理アドレスの対応を保持するARPテーブルを取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD GetIpNetTable(
    MIB_IPNETTABLE* IpNetTable,   // optional
    DWORD* SizePointer,
    BOOL Order
);

パラメーター

名前方向
IpNetTableMIB_IPNETTABLE*outoptional
SizePointerDWORD*inout
OrderBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetIpNetTable(
    MIB_IPNETTABLE* IpNetTable,   // optional
    DWORD* SizePointer,
    BOOL Order
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetIpNetTable(
    IntPtr IpNetTable,   // MIB_IPNETTABLE* optional, out
    ref uint SizePointer,   // DWORD* in/out
    bool Order   // BOOL
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetIpNetTable(
    IpNetTable As IntPtr,   ' MIB_IPNETTABLE* optional, out
    ByRef SizePointer As UInteger,   ' DWORD* in/out
    Order As Boolean   ' BOOL
) As UInteger
End Function
' IpNetTable : MIB_IPNETTABLE* optional, out
' SizePointer : DWORD* in/out
' Order : BOOL
Declare PtrSafe Function GetIpNetTable Lib "iphlpapi" ( _
    ByVal IpNetTable As LongPtr, _
    ByRef SizePointer As Long, _
    ByVal Order As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetIpNetTable = ctypes.windll.iphlpapi.GetIpNetTable
GetIpNetTable.restype = wintypes.DWORD
GetIpNetTable.argtypes = [
    ctypes.c_void_p,  # IpNetTable : MIB_IPNETTABLE* optional, out
    ctypes.POINTER(wintypes.DWORD),  # SizePointer : DWORD* in/out
    wintypes.BOOL,  # Order : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procGetIpNetTable = iphlpapi.NewProc("GetIpNetTable")
)

// IpNetTable (MIB_IPNETTABLE* optional, out), SizePointer (DWORD* in/out), Order (BOOL)
r1, _, err := procGetIpNetTable.Call(
	uintptr(IpNetTable),
	uintptr(SizePointer),
	uintptr(Order),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetIpNetTable(
  IpNetTable: Pointer;   // MIB_IPNETTABLE* optional, out
  SizePointer: Pointer;   // DWORD* in/out
  Order: BOOL   // BOOL
): DWORD; stdcall;
  external 'IPHLPAPI.dll' name 'GetIpNetTable';
result := DllCall("IPHLPAPI\GetIpNetTable"
    , "Ptr", IpNetTable   ; MIB_IPNETTABLE* optional, out
    , "Ptr", SizePointer   ; DWORD* in/out
    , "Int", Order   ; BOOL
    , "UInt")   ; return: DWORD
●GetIpNetTable(IpNetTable, SizePointer, Order) = DLL("IPHLPAPI.dll", "dword GetIpNetTable(void*, void*, bool)")
# 呼び出し: GetIpNetTable(IpNetTable, SizePointer, Order)
# IpNetTable : MIB_IPNETTABLE* optional, out -> "void*"
# SizePointer : DWORD* in/out -> "void*"
# Order : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。