ホーム › NetworkManagement.IpHelper › NotifyTeredoPortChange
NotifyTeredoPortChange
関数TeredoのUDPポート変更を通知するコールバックを登録する。
シグネチャ
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR NotifyTeredoPortChange(
PTEREDO_PORT_CHANGE_CALLBACK Callback,
void* CallerContext,
BOOLEAN InitialNotification,
HANDLE* NotificationHandle
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Callback | PTEREDO_PORT_CHANGE_CALLBACK | in |
| CallerContext | void* | in |
| InitialNotification | BOOLEAN | in |
| NotificationHandle | HANDLE* | inout |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR NotifyTeredoPortChange(
PTEREDO_PORT_CHANGE_CALLBACK Callback,
void* CallerContext,
BOOLEAN InitialNotification,
HANDLE* NotificationHandle
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint NotifyTeredoPortChange(
IntPtr Callback, // PTEREDO_PORT_CHANGE_CALLBACK
IntPtr CallerContext, // void*
[MarshalAs(UnmanagedType.U1)] bool InitialNotification, // BOOLEAN
IntPtr NotificationHandle // HANDLE* in/out
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function NotifyTeredoPortChange(
Callback As IntPtr, ' PTEREDO_PORT_CHANGE_CALLBACK
CallerContext As IntPtr, ' void*
<MarshalAs(UnmanagedType.U1)> InitialNotification As Boolean, ' BOOLEAN
NotificationHandle As IntPtr ' HANDLE* in/out
) As UInteger
End Function' Callback : PTEREDO_PORT_CHANGE_CALLBACK
' CallerContext : void*
' InitialNotification : BOOLEAN
' NotificationHandle : HANDLE* in/out
Declare PtrSafe Function NotifyTeredoPortChange Lib "iphlpapi" ( _
ByVal Callback As LongPtr, _
ByVal CallerContext As LongPtr, _
ByVal InitialNotification As Byte, _
ByVal NotificationHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NotifyTeredoPortChange = ctypes.windll.iphlpapi.NotifyTeredoPortChange
NotifyTeredoPortChange.restype = wintypes.DWORD
NotifyTeredoPortChange.argtypes = [
ctypes.c_void_p, # Callback : PTEREDO_PORT_CHANGE_CALLBACK
ctypes.POINTER(None), # CallerContext : void*
ctypes.c_byte, # InitialNotification : BOOLEAN
ctypes.c_void_p, # NotificationHandle : HANDLE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
NotifyTeredoPortChange = Fiddle::Function.new(
lib['NotifyTeredoPortChange'],
[
Fiddle::TYPE_VOIDP, # Callback : PTEREDO_PORT_CHANGE_CALLBACK
Fiddle::TYPE_VOIDP, # CallerContext : void*
Fiddle::TYPE_CHAR, # InitialNotification : BOOLEAN
Fiddle::TYPE_VOIDP, # NotificationHandle : HANDLE* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn NotifyTeredoPortChange(
Callback: *const core::ffi::c_void, // PTEREDO_PORT_CHANGE_CALLBACK
CallerContext: *mut (), // void*
InitialNotification: u8, // BOOLEAN
NotificationHandle: *mut *mut core::ffi::c_void // HANDLE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint NotifyTeredoPortChange(IntPtr Callback, IntPtr CallerContext, [MarshalAs(UnmanagedType.U1)] bool InitialNotification, IntPtr NotificationHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_NotifyTeredoPortChange' -Namespace Win32 -PassThru
# $api::NotifyTeredoPortChange(Callback, CallerContext, InitialNotification, NotificationHandle)#uselib "IPHLPAPI.dll"
#func global NotifyTeredoPortChange "NotifyTeredoPortChange" sptr, sptr, sptr, sptr
; NotifyTeredoPortChange Callback, CallerContext, InitialNotification, NotificationHandle ; 戻り値は stat
; Callback : PTEREDO_PORT_CHANGE_CALLBACK -> "sptr"
; CallerContext : void* -> "sptr"
; InitialNotification : BOOLEAN -> "sptr"
; NotificationHandle : HANDLE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "IPHLPAPI.dll"
#cfunc global NotifyTeredoPortChange "NotifyTeredoPortChange" sptr, sptr, int, sptr
; res = NotifyTeredoPortChange(Callback, CallerContext, InitialNotification, NotificationHandle)
; Callback : PTEREDO_PORT_CHANGE_CALLBACK -> "sptr"
; CallerContext : void* -> "sptr"
; InitialNotification : BOOLEAN -> "int"
; NotificationHandle : HANDLE* in/out -> "sptr"; WIN32_ERROR NotifyTeredoPortChange(PTEREDO_PORT_CHANGE_CALLBACK Callback, void* CallerContext, BOOLEAN InitialNotification, HANDLE* NotificationHandle)
#uselib "IPHLPAPI.dll"
#cfunc global NotifyTeredoPortChange "NotifyTeredoPortChange" intptr, intptr, int, intptr
; res = NotifyTeredoPortChange(Callback, CallerContext, InitialNotification, NotificationHandle)
; Callback : PTEREDO_PORT_CHANGE_CALLBACK -> "intptr"
; CallerContext : void* -> "intptr"
; InitialNotification : BOOLEAN -> "int"
; NotificationHandle : HANDLE* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procNotifyTeredoPortChange = iphlpapi.NewProc("NotifyTeredoPortChange")
)
// Callback (PTEREDO_PORT_CHANGE_CALLBACK), CallerContext (void*), InitialNotification (BOOLEAN), NotificationHandle (HANDLE* in/out)
r1, _, err := procNotifyTeredoPortChange.Call(
uintptr(Callback),
uintptr(CallerContext),
uintptr(InitialNotification),
uintptr(NotificationHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction NotifyTeredoPortChange(
Callback: Pointer; // PTEREDO_PORT_CHANGE_CALLBACK
CallerContext: Pointer; // void*
InitialNotification: ByteBool; // BOOLEAN
NotificationHandle: Pointer // HANDLE* in/out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'NotifyTeredoPortChange';result := DllCall("IPHLPAPI\NotifyTeredoPortChange"
, "Ptr", Callback ; PTEREDO_PORT_CHANGE_CALLBACK
, "Ptr", CallerContext ; void*
, "Char", InitialNotification ; BOOLEAN
, "Ptr", NotificationHandle ; HANDLE* in/out
, "UInt") ; return: WIN32_ERROR●NotifyTeredoPortChange(Callback, CallerContext, InitialNotification, NotificationHandle) = DLL("IPHLPAPI.dll", "dword NotifyTeredoPortChange(void*, void*, byte, void*)")
# 呼び出し: NotifyTeredoPortChange(Callback, CallerContext, InitialNotification, NotificationHandle)
# Callback : PTEREDO_PORT_CHANGE_CALLBACK -> "void*"
# CallerContext : void* -> "void*"
# InitialNotification : BOOLEAN -> "byte"
# NotificationHandle : HANDLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。