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

GetUdp6Table

関数
現在のIPv6 UDPエンドポイント一覧を取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD GetUdp6Table(
    MIB_UDP6TABLE* Udp6Table,   // optional
    DWORD* SizePointer,
    BOOL Order
);

パラメーター

名前方向
Udp6TableMIB_UDP6TABLE*outoptional
SizePointerDWORD*inout
OrderBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetUdp6Table(
    MIB_UDP6TABLE* Udp6Table,   // optional
    DWORD* SizePointer,
    BOOL Order
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetUdp6Table(
    IntPtr Udp6Table,   // MIB_UDP6TABLE* optional, out
    ref uint SizePointer,   // DWORD* in/out
    bool Order   // BOOL
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetUdp6Table(
    Udp6Table As IntPtr,   ' MIB_UDP6TABLE* optional, out
    ByRef SizePointer As UInteger,   ' DWORD* in/out
    Order As Boolean   ' BOOL
) As UInteger
End Function
' Udp6Table : MIB_UDP6TABLE* optional, out
' SizePointer : DWORD* in/out
' Order : BOOL
Declare PtrSafe Function GetUdp6Table Lib "iphlpapi" ( _
    ByVal Udp6Table 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

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

lib = Fiddle.dlopen('IPHLPAPI.dll')
GetUdp6Table = Fiddle::Function.new(
  lib['GetUdp6Table'],
  [
    Fiddle::TYPE_VOIDP,  # Udp6Table : MIB_UDP6TABLE* optional, out
    Fiddle::TYPE_VOIDP,  # SizePointer : DWORD* in/out
    Fiddle::TYPE_INT,  # Order : BOOL
  ],
  -Fiddle::TYPE_INT)
#[link(name = "iphlpapi")]
extern "system" {
    fn GetUdp6Table(
        Udp6Table: *mut MIB_UDP6TABLE,  // MIB_UDP6TABLE* 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 GetUdp6Table(IntPtr Udp6Table, ref uint SizePointer, bool Order);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetUdp6Table' -Namespace Win32 -PassThru
# $api::GetUdp6Table(Udp6Table, SizePointer, Order)
#uselib "IPHLPAPI.dll"
#func global GetUdp6Table "GetUdp6Table" sptr, sptr, sptr
; GetUdp6Table varptr(Udp6Table), varptr(SizePointer), Order   ; 戻り値は stat
; Udp6Table : MIB_UDP6TABLE* optional, out -> "sptr"
; SizePointer : DWORD* in/out -> "sptr"
; Order : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IPHLPAPI.dll"
#cfunc global GetUdp6Table "GetUdp6Table" var, var, int
; res = GetUdp6Table(Udp6Table, SizePointer, Order)
; Udp6Table : MIB_UDP6TABLE* optional, out -> "var"
; SizePointer : DWORD* in/out -> "var"
; Order : BOOL -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetUdp6Table(MIB_UDP6TABLE* Udp6Table, DWORD* SizePointer, BOOL Order)
#uselib "IPHLPAPI.dll"
#cfunc global GetUdp6Table "GetUdp6Table" var, var, int
; res = GetUdp6Table(Udp6Table, SizePointer, Order)
; Udp6Table : MIB_UDP6TABLE* 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")
	procGetUdp6Table = iphlpapi.NewProc("GetUdp6Table")
)

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