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