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