ホーム › NetworkManagement.IpHelper › PfBindInterfaceToIPAddress
PfBindInterfaceToIPAddress
関数パケットフィルタインターフェイスをIPアドレスにバインドする。
シグネチャ
// IPHLPAPI.dll
#include <windows.h>
DWORD PfBindInterfaceToIPAddress(
void* pInterface,
PFADDRESSTYPE pfatType,
BYTE* IPAddress
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pInterface | void* | inout |
| pfatType | PFADDRESSTYPE | in |
| IPAddress | BYTE* | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
DWORD PfBindInterfaceToIPAddress(
void* pInterface,
PFADDRESSTYPE pfatType,
BYTE* IPAddress
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint PfBindInterfaceToIPAddress(
IntPtr pInterface, // void* in/out
int pfatType, // PFADDRESSTYPE
IntPtr IPAddress // BYTE* in/out
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function PfBindInterfaceToIPAddress(
pInterface As IntPtr, ' void* in/out
pfatType As Integer, ' PFADDRESSTYPE
IPAddress As IntPtr ' BYTE* in/out
) As UInteger
End Function' pInterface : void* in/out
' pfatType : PFADDRESSTYPE
' IPAddress : BYTE* in/out
Declare PtrSafe Function PfBindInterfaceToIPAddress Lib "iphlpapi" ( _
ByVal pInterface As LongPtr, _
ByVal pfatType As Long, _
ByVal IPAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PfBindInterfaceToIPAddress = ctypes.windll.iphlpapi.PfBindInterfaceToIPAddress
PfBindInterfaceToIPAddress.restype = wintypes.DWORD
PfBindInterfaceToIPAddress.argtypes = [
ctypes.POINTER(None), # pInterface : void* in/out
ctypes.c_int, # pfatType : PFADDRESSTYPE
ctypes.POINTER(ctypes.c_ubyte), # IPAddress : BYTE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
PfBindInterfaceToIPAddress = Fiddle::Function.new(
lib['PfBindInterfaceToIPAddress'],
[
Fiddle::TYPE_VOIDP, # pInterface : void* in/out
Fiddle::TYPE_INT, # pfatType : PFADDRESSTYPE
Fiddle::TYPE_VOIDP, # IPAddress : BYTE* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn PfBindInterfaceToIPAddress(
pInterface: *mut (), // void* in/out
pfatType: i32, // PFADDRESSTYPE
IPAddress: *mut u8 // BYTE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint PfBindInterfaceToIPAddress(IntPtr pInterface, int pfatType, IntPtr IPAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_PfBindInterfaceToIPAddress' -Namespace Win32 -PassThru
# $api::PfBindInterfaceToIPAddress(pInterface, pfatType, IPAddress)#uselib "IPHLPAPI.dll"
#func global PfBindInterfaceToIPAddress "PfBindInterfaceToIPAddress" sptr, sptr, sptr
; PfBindInterfaceToIPAddress pInterface, pfatType, varptr(IPAddress) ; 戻り値は stat
; pInterface : void* in/out -> "sptr"
; pfatType : PFADDRESSTYPE -> "sptr"
; IPAddress : BYTE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "IPHLPAPI.dll" #cfunc global PfBindInterfaceToIPAddress "PfBindInterfaceToIPAddress" sptr, int, var ; res = PfBindInterfaceToIPAddress(pInterface, pfatType, IPAddress) ; pInterface : void* in/out -> "sptr" ; pfatType : PFADDRESSTYPE -> "int" ; IPAddress : BYTE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global PfBindInterfaceToIPAddress "PfBindInterfaceToIPAddress" sptr, int, sptr ; res = PfBindInterfaceToIPAddress(pInterface, pfatType, varptr(IPAddress)) ; pInterface : void* in/out -> "sptr" ; pfatType : PFADDRESSTYPE -> "int" ; IPAddress : BYTE* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PfBindInterfaceToIPAddress(void* pInterface, PFADDRESSTYPE pfatType, BYTE* IPAddress) #uselib "IPHLPAPI.dll" #cfunc global PfBindInterfaceToIPAddress "PfBindInterfaceToIPAddress" intptr, int, var ; res = PfBindInterfaceToIPAddress(pInterface, pfatType, IPAddress) ; pInterface : void* in/out -> "intptr" ; pfatType : PFADDRESSTYPE -> "int" ; IPAddress : BYTE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PfBindInterfaceToIPAddress(void* pInterface, PFADDRESSTYPE pfatType, BYTE* IPAddress) #uselib "IPHLPAPI.dll" #cfunc global PfBindInterfaceToIPAddress "PfBindInterfaceToIPAddress" intptr, int, intptr ; res = PfBindInterfaceToIPAddress(pInterface, pfatType, varptr(IPAddress)) ; pInterface : void* in/out -> "intptr" ; pfatType : PFADDRESSTYPE -> "int" ; IPAddress : BYTE* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procPfBindInterfaceToIPAddress = iphlpapi.NewProc("PfBindInterfaceToIPAddress")
)
// pInterface (void* in/out), pfatType (PFADDRESSTYPE), IPAddress (BYTE* in/out)
r1, _, err := procPfBindInterfaceToIPAddress.Call(
uintptr(pInterface),
uintptr(pfatType),
uintptr(IPAddress),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PfBindInterfaceToIPAddress(
pInterface: Pointer; // void* in/out
pfatType: Integer; // PFADDRESSTYPE
IPAddress: Pointer // BYTE* in/out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'PfBindInterfaceToIPAddress';result := DllCall("IPHLPAPI\PfBindInterfaceToIPAddress"
, "Ptr", pInterface ; void* in/out
, "Int", pfatType ; PFADDRESSTYPE
, "Ptr", IPAddress ; BYTE* in/out
, "UInt") ; return: DWORD●PfBindInterfaceToIPAddress(pInterface, pfatType, IPAddress) = DLL("IPHLPAPI.dll", "dword PfBindInterfaceToIPAddress(void*, int, void*)")
# 呼び出し: PfBindInterfaceToIPAddress(pInterface, pfatType, IPAddress)
# pInterface : void* in/out -> "void*"
# pfatType : PFADDRESSTYPE -> "int"
# IPAddress : BYTE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。