Win32 API 日本語リファレンス
ホームNetworkManagement.Rras › RtmLockRoute

RtmLockRoute

関数
指定したルートをロックし情報ポインタを取得する。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

// rtm.dll
#include <windows.h>

DWORD RtmLockRoute(
    INT_PTR RtmRegHandle,
    INT_PTR RouteHandle,
    BOOL Exclusive,
    BOOL LockRoute,
    RTM_ROUTE_INFO** RoutePointer
);

パラメーター

名前方向
RtmRegHandleINT_PTRin
RouteHandleINT_PTRin
ExclusiveBOOLin
LockRouteBOOLin
RoutePointerRTM_ROUTE_INFO**inout

戻り値の型: DWORD

各言語での呼び出し定義

// rtm.dll
#include <windows.h>

DWORD RtmLockRoute(
    INT_PTR RtmRegHandle,
    INT_PTR RouteHandle,
    BOOL Exclusive,
    BOOL LockRoute,
    RTM_ROUTE_INFO** RoutePointer
);
[DllImport("rtm.dll", ExactSpelling = true)]
static extern uint RtmLockRoute(
    IntPtr RtmRegHandle,   // INT_PTR
    IntPtr RouteHandle,   // INT_PTR
    bool Exclusive,   // BOOL
    bool LockRoute,   // BOOL
    IntPtr RoutePointer   // RTM_ROUTE_INFO** in/out
);
<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function RtmLockRoute(
    RtmRegHandle As IntPtr,   ' INT_PTR
    RouteHandle As IntPtr,   ' INT_PTR
    Exclusive As Boolean,   ' BOOL
    LockRoute As Boolean,   ' BOOL
    RoutePointer As IntPtr   ' RTM_ROUTE_INFO** in/out
) As UInteger
End Function
' RtmRegHandle : INT_PTR
' RouteHandle : INT_PTR
' Exclusive : BOOL
' LockRoute : BOOL
' RoutePointer : RTM_ROUTE_INFO** in/out
Declare PtrSafe Function RtmLockRoute Lib "rtm" ( _
    ByVal RtmRegHandle As LongPtr, _
    ByVal RouteHandle As LongPtr, _
    ByVal Exclusive As Long, _
    ByVal LockRoute As Long, _
    ByVal RoutePointer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtmLockRoute = ctypes.windll.rtm.RtmLockRoute
RtmLockRoute.restype = wintypes.DWORD
RtmLockRoute.argtypes = [
    ctypes.c_ssize_t,  # RtmRegHandle : INT_PTR
    ctypes.c_ssize_t,  # RouteHandle : INT_PTR
    wintypes.BOOL,  # Exclusive : BOOL
    wintypes.BOOL,  # LockRoute : BOOL
    ctypes.c_void_p,  # RoutePointer : RTM_ROUTE_INFO** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rtm.dll')
RtmLockRoute = Fiddle::Function.new(
  lib['RtmLockRoute'],
  [
    Fiddle::TYPE_INTPTR_T,  # RtmRegHandle : INT_PTR
    Fiddle::TYPE_INTPTR_T,  # RouteHandle : INT_PTR
    Fiddle::TYPE_INT,  # Exclusive : BOOL
    Fiddle::TYPE_INT,  # LockRoute : BOOL
    Fiddle::TYPE_VOIDP,  # RoutePointer : RTM_ROUTE_INFO** in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "rtm")]
extern "system" {
    fn RtmLockRoute(
        RtmRegHandle: isize,  // INT_PTR
        RouteHandle: isize,  // INT_PTR
        Exclusive: i32,  // BOOL
        LockRoute: i32,  // BOOL
        RoutePointer: *mut *mut RTM_ROUTE_INFO  // RTM_ROUTE_INFO** in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rtm.dll")]
public static extern uint RtmLockRoute(IntPtr RtmRegHandle, IntPtr RouteHandle, bool Exclusive, bool LockRoute, IntPtr RoutePointer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtm_RtmLockRoute' -Namespace Win32 -PassThru
# $api::RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
#uselib "rtm.dll"
#func global RtmLockRoute "RtmLockRoute" sptr, sptr, sptr, sptr, sptr
; RtmLockRoute RtmRegHandle, RouteHandle, Exclusive, LockRoute, varptr(RoutePointer)   ; 戻り値は stat
; RtmRegHandle : INT_PTR -> "sptr"
; RouteHandle : INT_PTR -> "sptr"
; Exclusive : BOOL -> "sptr"
; LockRoute : BOOL -> "sptr"
; RoutePointer : RTM_ROUTE_INFO** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "rtm.dll"
#cfunc global RtmLockRoute "RtmLockRoute" sptr, sptr, int, int, var
; res = RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
; RtmRegHandle : INT_PTR -> "sptr"
; RouteHandle : INT_PTR -> "sptr"
; Exclusive : BOOL -> "int"
; LockRoute : BOOL -> "int"
; RoutePointer : RTM_ROUTE_INFO** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD RtmLockRoute(INT_PTR RtmRegHandle, INT_PTR RouteHandle, BOOL Exclusive, BOOL LockRoute, RTM_ROUTE_INFO** RoutePointer)
#uselib "rtm.dll"
#cfunc global RtmLockRoute "RtmLockRoute" intptr, intptr, int, int, var
; res = RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
; RtmRegHandle : INT_PTR -> "intptr"
; RouteHandle : INT_PTR -> "intptr"
; Exclusive : BOOL -> "int"
; LockRoute : BOOL -> "int"
; RoutePointer : RTM_ROUTE_INFO** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procRtmLockRoute = rtm.NewProc("RtmLockRoute")
)

// RtmRegHandle (INT_PTR), RouteHandle (INT_PTR), Exclusive (BOOL), LockRoute (BOOL), RoutePointer (RTM_ROUTE_INFO** in/out)
r1, _, err := procRtmLockRoute.Call(
	uintptr(RtmRegHandle),
	uintptr(RouteHandle),
	uintptr(Exclusive),
	uintptr(LockRoute),
	uintptr(RoutePointer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RtmLockRoute(
  RtmRegHandle: NativeInt;   // INT_PTR
  RouteHandle: NativeInt;   // INT_PTR
  Exclusive: BOOL;   // BOOL
  LockRoute: BOOL;   // BOOL
  RoutePointer: Pointer   // RTM_ROUTE_INFO** in/out
): DWORD; stdcall;
  external 'rtm.dll' name 'RtmLockRoute';
result := DllCall("rtm\RtmLockRoute"
    , "Ptr", RtmRegHandle   ; INT_PTR
    , "Ptr", RouteHandle   ; INT_PTR
    , "Int", Exclusive   ; BOOL
    , "Int", LockRoute   ; BOOL
    , "Ptr", RoutePointer   ; RTM_ROUTE_INFO** in/out
    , "UInt")   ; return: DWORD
●RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer) = DLL("rtm.dll", "dword RtmLockRoute(int, int, bool, bool, void*)")
# 呼び出し: RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
# RtmRegHandle : INT_PTR -> "int"
# RouteHandle : INT_PTR -> "int"
# Exclusive : BOOL -> "bool"
# LockRoute : BOOL -> "bool"
# RoutePointer : RTM_ROUTE_INFO** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。