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