ホーム › NetworkManagement.Rras › RtmGetExactMatchDestination
RtmGetExactMatchDestination
関数指定アドレスに完全一致する宛先を取得する。
シグネチャ
// rtm.dll
#include <windows.h>
DWORD RtmGetExactMatchDestination(
INT_PTR RtmRegHandle,
RTM_NET_ADDRESS* DestAddress,
DWORD ProtocolId,
DWORD TargetViews,
RTM_DEST_INFO* DestInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| RtmRegHandle | INT_PTR | in | RtmRegisterEntityで取得したRTM登録ハンドル。 |
| DestAddress | RTM_NET_ADDRESS* | inout | 完全一致を検索する宛先ネットワークアドレスを示すRTM_NET_ADDRESS構造体へのポインタ。 |
| ProtocolId | DWORD | in | 対象とするルーティングプロトコルの識別子。 |
| TargetViews | DWORD | in | 検索対象とするビューのマスク。 |
| DestInfo | RTM_DEST_INFO* | inout | 見つかった宛先情報を受け取るRTM_DEST_INFO構造体へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// rtm.dll
#include <windows.h>
DWORD RtmGetExactMatchDestination(
INT_PTR RtmRegHandle,
RTM_NET_ADDRESS* DestAddress,
DWORD ProtocolId,
DWORD TargetViews,
RTM_DEST_INFO* DestInfo
);[DllImport("rtm.dll", ExactSpelling = true)]
static extern uint RtmGetExactMatchDestination(
IntPtr RtmRegHandle, // INT_PTR
IntPtr DestAddress, // RTM_NET_ADDRESS* in/out
uint ProtocolId, // DWORD
uint TargetViews, // DWORD
IntPtr DestInfo // RTM_DEST_INFO* in/out
);<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function RtmGetExactMatchDestination(
RtmRegHandle As IntPtr, ' INT_PTR
DestAddress As IntPtr, ' RTM_NET_ADDRESS* in/out
ProtocolId As UInteger, ' DWORD
TargetViews As UInteger, ' DWORD
DestInfo As IntPtr ' RTM_DEST_INFO* in/out
) As UInteger
End Function' RtmRegHandle : INT_PTR
' DestAddress : RTM_NET_ADDRESS* in/out
' ProtocolId : DWORD
' TargetViews : DWORD
' DestInfo : RTM_DEST_INFO* in/out
Declare PtrSafe Function RtmGetExactMatchDestination Lib "rtm" ( _
ByVal RtmRegHandle As LongPtr, _
ByVal DestAddress As LongPtr, _
ByVal ProtocolId As Long, _
ByVal TargetViews As Long, _
ByVal DestInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RtmGetExactMatchDestination = ctypes.windll.rtm.RtmGetExactMatchDestination
RtmGetExactMatchDestination.restype = wintypes.DWORD
RtmGetExactMatchDestination.argtypes = [
ctypes.c_ssize_t, # RtmRegHandle : INT_PTR
ctypes.c_void_p, # DestAddress : RTM_NET_ADDRESS* in/out
wintypes.DWORD, # ProtocolId : DWORD
wintypes.DWORD, # TargetViews : DWORD
ctypes.c_void_p, # DestInfo : RTM_DEST_INFO* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('rtm.dll')
RtmGetExactMatchDestination = Fiddle::Function.new(
lib['RtmGetExactMatchDestination'],
[
Fiddle::TYPE_INTPTR_T, # RtmRegHandle : INT_PTR
Fiddle::TYPE_VOIDP, # DestAddress : RTM_NET_ADDRESS* in/out
-Fiddle::TYPE_INT, # ProtocolId : DWORD
-Fiddle::TYPE_INT, # TargetViews : DWORD
Fiddle::TYPE_VOIDP, # DestInfo : RTM_DEST_INFO* in/out
],
-Fiddle::TYPE_INT)#[link(name = "rtm")]
extern "system" {
fn RtmGetExactMatchDestination(
RtmRegHandle: isize, // INT_PTR
DestAddress: *mut RTM_NET_ADDRESS, // RTM_NET_ADDRESS* in/out
ProtocolId: u32, // DWORD
TargetViews: u32, // DWORD
DestInfo: *mut RTM_DEST_INFO // RTM_DEST_INFO* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("rtm.dll")]
public static extern uint RtmGetExactMatchDestination(IntPtr RtmRegHandle, IntPtr DestAddress, uint ProtocolId, uint TargetViews, IntPtr DestInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtm_RtmGetExactMatchDestination' -Namespace Win32 -PassThru
# $api::RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)#uselib "rtm.dll"
#func global RtmGetExactMatchDestination "RtmGetExactMatchDestination" sptr, sptr, sptr, sptr, sptr
; RtmGetExactMatchDestination RtmRegHandle, varptr(DestAddress), ProtocolId, TargetViews, varptr(DestInfo) ; 戻り値は stat
; RtmRegHandle : INT_PTR -> "sptr"
; DestAddress : RTM_NET_ADDRESS* in/out -> "sptr"
; ProtocolId : DWORD -> "sptr"
; TargetViews : DWORD -> "sptr"
; DestInfo : RTM_DEST_INFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "rtm.dll" #cfunc global RtmGetExactMatchDestination "RtmGetExactMatchDestination" sptr, var, int, int, var ; res = RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo) ; RtmRegHandle : INT_PTR -> "sptr" ; DestAddress : RTM_NET_ADDRESS* in/out -> "var" ; ProtocolId : DWORD -> "int" ; TargetViews : DWORD -> "int" ; DestInfo : RTM_DEST_INFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "rtm.dll" #cfunc global RtmGetExactMatchDestination "RtmGetExactMatchDestination" sptr, sptr, int, int, sptr ; res = RtmGetExactMatchDestination(RtmRegHandle, varptr(DestAddress), ProtocolId, TargetViews, varptr(DestInfo)) ; RtmRegHandle : INT_PTR -> "sptr" ; DestAddress : RTM_NET_ADDRESS* in/out -> "sptr" ; ProtocolId : DWORD -> "int" ; TargetViews : DWORD -> "int" ; DestInfo : RTM_DEST_INFO* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RtmGetExactMatchDestination(INT_PTR RtmRegHandle, RTM_NET_ADDRESS* DestAddress, DWORD ProtocolId, DWORD TargetViews, RTM_DEST_INFO* DestInfo) #uselib "rtm.dll" #cfunc global RtmGetExactMatchDestination "RtmGetExactMatchDestination" intptr, var, int, int, var ; res = RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo) ; RtmRegHandle : INT_PTR -> "intptr" ; DestAddress : RTM_NET_ADDRESS* in/out -> "var" ; ProtocolId : DWORD -> "int" ; TargetViews : DWORD -> "int" ; DestInfo : RTM_DEST_INFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RtmGetExactMatchDestination(INT_PTR RtmRegHandle, RTM_NET_ADDRESS* DestAddress, DWORD ProtocolId, DWORD TargetViews, RTM_DEST_INFO* DestInfo) #uselib "rtm.dll" #cfunc global RtmGetExactMatchDestination "RtmGetExactMatchDestination" intptr, intptr, int, int, intptr ; res = RtmGetExactMatchDestination(RtmRegHandle, varptr(DestAddress), ProtocolId, TargetViews, varptr(DestInfo)) ; RtmRegHandle : INT_PTR -> "intptr" ; DestAddress : RTM_NET_ADDRESS* in/out -> "intptr" ; ProtocolId : DWORD -> "int" ; TargetViews : DWORD -> "int" ; DestInfo : RTM_DEST_INFO* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rtm = windows.NewLazySystemDLL("rtm.dll")
procRtmGetExactMatchDestination = rtm.NewProc("RtmGetExactMatchDestination")
)
// RtmRegHandle (INT_PTR), DestAddress (RTM_NET_ADDRESS* in/out), ProtocolId (DWORD), TargetViews (DWORD), DestInfo (RTM_DEST_INFO* in/out)
r1, _, err := procRtmGetExactMatchDestination.Call(
uintptr(RtmRegHandle),
uintptr(DestAddress),
uintptr(ProtocolId),
uintptr(TargetViews),
uintptr(DestInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RtmGetExactMatchDestination(
RtmRegHandle: NativeInt; // INT_PTR
DestAddress: Pointer; // RTM_NET_ADDRESS* in/out
ProtocolId: DWORD; // DWORD
TargetViews: DWORD; // DWORD
DestInfo: Pointer // RTM_DEST_INFO* in/out
): DWORD; stdcall;
external 'rtm.dll' name 'RtmGetExactMatchDestination';result := DllCall("rtm\RtmGetExactMatchDestination"
, "Ptr", RtmRegHandle ; INT_PTR
, "Ptr", DestAddress ; RTM_NET_ADDRESS* in/out
, "UInt", ProtocolId ; DWORD
, "UInt", TargetViews ; DWORD
, "Ptr", DestInfo ; RTM_DEST_INFO* in/out
, "UInt") ; return: DWORD●RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo) = DLL("rtm.dll", "dword RtmGetExactMatchDestination(int, void*, dword, dword, void*)")
# 呼び出し: RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)
# RtmRegHandle : INT_PTR -> "int"
# DestAddress : RTM_NET_ADDRESS* in/out -> "void*"
# ProtocolId : DWORD -> "dword"
# TargetViews : DWORD -> "dword"
# DestInfo : RTM_DEST_INFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rtm" fn RtmGetExactMatchDestination(
RtmRegHandle: isize, // INT_PTR
DestAddress: [*c]RTM_NET_ADDRESS, // RTM_NET_ADDRESS* in/out
ProtocolId: u32, // DWORD
TargetViews: u32, // DWORD
DestInfo: [*c]RTM_DEST_INFO // RTM_DEST_INFO* in/out
) callconv(std.os.windows.WINAPI) u32;proc RtmGetExactMatchDestination(
RtmRegHandle: int, # INT_PTR
DestAddress: ptr RTM_NET_ADDRESS, # RTM_NET_ADDRESS* in/out
ProtocolId: uint32, # DWORD
TargetViews: uint32, # DWORD
DestInfo: ptr RTM_DEST_INFO # RTM_DEST_INFO* in/out
): uint32 {.importc: "RtmGetExactMatchDestination", stdcall, dynlib: "rtm.dll".}pragma(lib, "rtm");
extern(Windows)
uint RtmGetExactMatchDestination(
ptrdiff_t RtmRegHandle, // INT_PTR
RTM_NET_ADDRESS* DestAddress, // RTM_NET_ADDRESS* in/out
uint ProtocolId, // DWORD
uint TargetViews, // DWORD
RTM_DEST_INFO* DestInfo // RTM_DEST_INFO* in/out
);ccall((:RtmGetExactMatchDestination, "rtm.dll"), stdcall, UInt32,
(Int, Ptr{RTM_NET_ADDRESS}, UInt32, UInt32, Ptr{RTM_DEST_INFO}),
RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)
# RtmRegHandle : INT_PTR -> Int
# DestAddress : RTM_NET_ADDRESS* in/out -> Ptr{RTM_NET_ADDRESS}
# ProtocolId : DWORD -> UInt32
# TargetViews : DWORD -> UInt32
# DestInfo : RTM_DEST_INFO* in/out -> Ptr{RTM_DEST_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RtmGetExactMatchDestination(
intptr_t RtmRegHandle,
void* DestAddress,
uint32_t ProtocolId,
uint32_t TargetViews,
void* DestInfo);
]]
local rtm = ffi.load("rtm")
-- rtm.RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)
-- RtmRegHandle : INT_PTR
-- DestAddress : RTM_NET_ADDRESS* in/out
-- ProtocolId : DWORD
-- TargetViews : DWORD
-- DestInfo : RTM_DEST_INFO* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('rtm.dll');
const RtmGetExactMatchDestination = lib.func('__stdcall', 'RtmGetExactMatchDestination', 'uint32_t', ['intptr_t', 'void *', 'uint32_t', 'uint32_t', 'void *']);
// RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)
// RtmRegHandle : INT_PTR -> 'intptr_t'
// DestAddress : RTM_NET_ADDRESS* in/out -> 'void *'
// ProtocolId : DWORD -> 'uint32_t'
// TargetViews : DWORD -> 'uint32_t'
// DestInfo : RTM_DEST_INFO* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("rtm.dll", {
RtmGetExactMatchDestination: { parameters: ["isize", "pointer", "u32", "u32", "pointer"], result: "u32" },
});
// lib.symbols.RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo)
// RtmRegHandle : INT_PTR -> "isize"
// DestAddress : RTM_NET_ADDRESS* in/out -> "pointer"
// ProtocolId : DWORD -> "u32"
// TargetViews : DWORD -> "u32"
// DestInfo : RTM_DEST_INFO* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RtmGetExactMatchDestination(
intptr_t RtmRegHandle,
void* DestAddress,
uint32_t ProtocolId,
uint32_t TargetViews,
void* DestInfo);
C, "rtm.dll");
// $ffi->RtmGetExactMatchDestination(RtmRegHandle, DestAddress, ProtocolId, TargetViews, DestInfo);
// RtmRegHandle : INT_PTR
// DestAddress : RTM_NET_ADDRESS* in/out
// ProtocolId : DWORD
// TargetViews : DWORD
// DestInfo : RTM_DEST_INFO* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Rtm extends StdCallLibrary {
Rtm INSTANCE = Native.load("rtm", Rtm.class);
int RtmGetExactMatchDestination(
long RtmRegHandle, // INT_PTR
Pointer DestAddress, // RTM_NET_ADDRESS* in/out
int ProtocolId, // DWORD
int TargetViews, // DWORD
Pointer DestInfo // RTM_DEST_INFO* in/out
);
}@[Link("rtm")]
lib Librtm
fun RtmGetExactMatchDestination = RtmGetExactMatchDestination(
RtmRegHandle : LibC::SSizeT, # INT_PTR
DestAddress : RTM_NET_ADDRESS*, # RTM_NET_ADDRESS* in/out
ProtocolId : UInt32, # DWORD
TargetViews : UInt32, # DWORD
DestInfo : RTM_DEST_INFO* # RTM_DEST_INFO* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtmGetExactMatchDestinationNative = Uint32 Function(IntPtr, Pointer<Void>, Uint32, Uint32, Pointer<Void>);
typedef RtmGetExactMatchDestinationDart = int Function(int, Pointer<Void>, int, int, Pointer<Void>);
final RtmGetExactMatchDestination = DynamicLibrary.open('rtm.dll')
.lookupFunction<RtmGetExactMatchDestinationNative, RtmGetExactMatchDestinationDart>('RtmGetExactMatchDestination');
// RtmRegHandle : INT_PTR -> IntPtr
// DestAddress : RTM_NET_ADDRESS* in/out -> Pointer<Void>
// ProtocolId : DWORD -> Uint32
// TargetViews : DWORD -> Uint32
// DestInfo : RTM_DEST_INFO* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtmGetExactMatchDestination(
RtmRegHandle: NativeInt; // INT_PTR
DestAddress: Pointer; // RTM_NET_ADDRESS* in/out
ProtocolId: DWORD; // DWORD
TargetViews: DWORD; // DWORD
DestInfo: Pointer // RTM_DEST_INFO* in/out
): DWORD; stdcall;
external 'rtm.dll' name 'RtmGetExactMatchDestination';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtmGetExactMatchDestination"
c_RtmGetExactMatchDestination :: CIntPtr -> Ptr () -> Word32 -> Word32 -> Ptr () -> IO Word32
-- RtmRegHandle : INT_PTR -> CIntPtr
-- DestAddress : RTM_NET_ADDRESS* in/out -> Ptr ()
-- ProtocolId : DWORD -> Word32
-- TargetViews : DWORD -> Word32
-- DestInfo : RTM_DEST_INFO* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtmgetexactmatchdestination =
foreign "RtmGetExactMatchDestination"
(intptr_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* RtmRegHandle : INT_PTR -> intptr_t *)
(* DestAddress : RTM_NET_ADDRESS* in/out -> (ptr void) *)
(* ProtocolId : DWORD -> uint32_t *)
(* TargetViews : DWORD -> uint32_t *)
(* DestInfo : RTM_DEST_INFO* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rtm (t "rtm.dll"))
(cffi:use-foreign-library rtm)
(cffi:defcfun ("RtmGetExactMatchDestination" rtm-get-exact-match-destination :convention :stdcall) :uint32
(rtm-reg-handle :int64) ; INT_PTR
(dest-address :pointer) ; RTM_NET_ADDRESS* in/out
(protocol-id :uint32) ; DWORD
(target-views :uint32) ; DWORD
(dest-info :pointer)) ; RTM_DEST_INFO* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtmGetExactMatchDestination = Win32::API::More->new('rtm',
'DWORD RtmGetExactMatchDestination(LPARAM RtmRegHandle, LPVOID DestAddress, DWORD ProtocolId, DWORD TargetViews, LPVOID DestInfo)');
# my $ret = $RtmGetExactMatchDestination->Call($RtmRegHandle, $DestAddress, $ProtocolId, $TargetViews, $DestInfo);
# RtmRegHandle : INT_PTR -> LPARAM
# DestAddress : RTM_NET_ADDRESS* in/out -> LPVOID
# ProtocolId : DWORD -> DWORD
# TargetViews : DWORD -> DWORD
# DestInfo : RTM_DEST_INFO* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。