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_PTRinRtmRegisterEntityで取得したRTM登録ハンドル。
RouteHandleINT_PTRinロック/アンロックする対象ルートのハンドル。
ExclusiveBOOLinTRUEなら排他(書き込み)ロック、FALSEなら共有(読み取り)ロックを取得する。
LockRouteBOOLinTRUEならロックを取得し、FALSEならロックを解放する。
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)。
const std = @import("std");

extern "rtm" fn RtmLockRoute(
    RtmRegHandle: isize, // INT_PTR
    RouteHandle: isize, // INT_PTR
    Exclusive: i32, // BOOL
    LockRoute: i32, // BOOL
    RoutePointer: [*c][*c]RTM_ROUTE_INFO // RTM_ROUTE_INFO** in/out
) callconv(std.os.windows.WINAPI) u32;
proc RtmLockRoute(
    RtmRegHandle: int,  # INT_PTR
    RouteHandle: int,  # INT_PTR
    Exclusive: int32,  # BOOL
    LockRoute: int32,  # BOOL
    RoutePointer: ptr RTM_ROUTE_INFO  # RTM_ROUTE_INFO** in/out
): uint32 {.importc: "RtmLockRoute", stdcall, dynlib: "rtm.dll".}
pragma(lib, "rtm");
extern(Windows)
uint RtmLockRoute(
    ptrdiff_t RtmRegHandle,   // INT_PTR
    ptrdiff_t RouteHandle,   // INT_PTR
    int Exclusive,   // BOOL
    int LockRoute,   // BOOL
    RTM_ROUTE_INFO** RoutePointer   // RTM_ROUTE_INFO** in/out
);
ccall((:RtmLockRoute, "rtm.dll"), stdcall, UInt32,
      (Int, Int, Int32, Int32, Ptr{RTM_ROUTE_INFO}),
      RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
# RtmRegHandle : INT_PTR -> Int
# RouteHandle : INT_PTR -> Int
# Exclusive : BOOL -> Int32
# LockRoute : BOOL -> Int32
# RoutePointer : RTM_ROUTE_INFO** in/out -> Ptr{RTM_ROUTE_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t RtmLockRoute(
    intptr_t RtmRegHandle,
    intptr_t RouteHandle,
    int32_t Exclusive,
    int32_t LockRoute,
    void* RoutePointer);
]]
local rtm = ffi.load("rtm")
-- rtm.RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
-- RtmRegHandle : INT_PTR
-- RouteHandle : INT_PTR
-- Exclusive : BOOL
-- LockRoute : BOOL
-- RoutePointer : RTM_ROUTE_INFO** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('rtm.dll');
const RtmLockRoute = lib.func('__stdcall', 'RtmLockRoute', 'uint32_t', ['intptr_t', 'intptr_t', 'int32_t', 'int32_t', 'void *']);
// RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
// RtmRegHandle : INT_PTR -> 'intptr_t'
// RouteHandle : INT_PTR -> 'intptr_t'
// Exclusive : BOOL -> 'int32_t'
// LockRoute : BOOL -> 'int32_t'
// RoutePointer : RTM_ROUTE_INFO** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("rtm.dll", {
  RtmLockRoute: { parameters: ["isize", "isize", "i32", "i32", "pointer"], result: "u32" },
});
// lib.symbols.RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer)
// RtmRegHandle : INT_PTR -> "isize"
// RouteHandle : INT_PTR -> "isize"
// Exclusive : BOOL -> "i32"
// LockRoute : BOOL -> "i32"
// RoutePointer : RTM_ROUTE_INFO** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t RtmLockRoute(
    intptr_t RtmRegHandle,
    intptr_t RouteHandle,
    int32_t Exclusive,
    int32_t LockRoute,
    void* RoutePointer);
C, "rtm.dll");
// $ffi->RtmLockRoute(RtmRegHandle, RouteHandle, Exclusive, LockRoute, RoutePointer);
// RtmRegHandle : INT_PTR
// RouteHandle : INT_PTR
// Exclusive : BOOL
// LockRoute : BOOL
// RoutePointer : RTM_ROUTE_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 RtmLockRoute(
        long RtmRegHandle,   // INT_PTR
        long RouteHandle,   // INT_PTR
        boolean Exclusive,   // BOOL
        boolean LockRoute,   // BOOL
        Pointer RoutePointer   // RTM_ROUTE_INFO** in/out
    );
}
@[Link("rtm")]
lib Librtm
  fun RtmLockRoute = RtmLockRoute(
    RtmRegHandle : LibC::SSizeT,   # INT_PTR
    RouteHandle : LibC::SSizeT,   # INT_PTR
    Exclusive : Int32,   # BOOL
    LockRoute : Int32,   # BOOL
    RoutePointer : RTM_ROUTE_INFO**   # RTM_ROUTE_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 RtmLockRouteNative = Uint32 Function(IntPtr, IntPtr, Int32, Int32, Pointer<Void>);
typedef RtmLockRouteDart = int Function(int, int, int, int, Pointer<Void>);
final RtmLockRoute = DynamicLibrary.open('rtm.dll')
    .lookupFunction<RtmLockRouteNative, RtmLockRouteDart>('RtmLockRoute');
// RtmRegHandle : INT_PTR -> IntPtr
// RouteHandle : INT_PTR -> IntPtr
// Exclusive : BOOL -> Int32
// LockRoute : BOOL -> Int32
// RoutePointer : RTM_ROUTE_INFO** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RtmLockRoute"
  c_RtmLockRoute :: CIntPtr -> CIntPtr -> CInt -> CInt -> Ptr () -> IO Word32
-- RtmRegHandle : INT_PTR -> CIntPtr
-- RouteHandle : INT_PTR -> CIntPtr
-- Exclusive : BOOL -> CInt
-- LockRoute : BOOL -> CInt
-- RoutePointer : RTM_ROUTE_INFO** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rtmlockroute =
  foreign "RtmLockRoute"
    (intptr_t @-> intptr_t @-> int32_t @-> int32_t @-> (ptr void) @-> returning uint32_t)
(* RtmRegHandle : INT_PTR -> intptr_t *)
(* RouteHandle : INT_PTR -> intptr_t *)
(* Exclusive : BOOL -> int32_t *)
(* LockRoute : BOOL -> int32_t *)
(* RoutePointer : RTM_ROUTE_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 ("RtmLockRoute" rtm-lock-route :convention :stdcall) :uint32
  (rtm-reg-handle :int64)   ; INT_PTR
  (route-handle :int64)   ; INT_PTR
  (exclusive :int32)   ; BOOL
  (lock-route :int32)   ; BOOL
  (route-pointer :pointer))   ; RTM_ROUTE_INFO** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RtmLockRoute = Win32::API::More->new('rtm',
    'DWORD RtmLockRoute(LPARAM RtmRegHandle, LPARAM RouteHandle, BOOL Exclusive, BOOL LockRoute, LPVOID RoutePointer)');
# my $ret = $RtmLockRoute->Call($RtmRegHandle, $RouteHandle, $Exclusive, $LockRoute, $RoutePointer);
# RtmRegHandle : INT_PTR -> LPARAM
# RouteHandle : INT_PTR -> LPARAM
# Exclusive : BOOL -> BOOL
# LockRoute : BOOL -> BOOL
# RoutePointer : RTM_ROUTE_INFO** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型