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

GetTcp6Table

関数
現在のIPv6 TCP接続一覧をMIB_TCP6TABLEとして取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD GetTcp6Table(
    MIB_TCP6TABLE* TcpTable,
    DWORD* SizePointer,
    BOOL Order
);

パラメーター

名前方向
TcpTableMIB_TCP6TABLE*out
SizePointerDWORD*inout
OrderBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

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