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

GetTeredoPort

関数
Teredoが使用するUDPポート番号を取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR GetTeredoPort(
    WORD* Port
);

パラメーター

名前方向
PortWORD*out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

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

GetTeredoPort = ctypes.windll.iphlpapi.GetTeredoPort
GetTeredoPort.restype = wintypes.DWORD
GetTeredoPort.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # Port : WORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procGetTeredoPort = iphlpapi.NewProc("GetTeredoPort")
)

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