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

RtmLockDestination

関数
ルーティングの宛先を排他または共有ロックする。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD RtmLockDestination(
    INT_PTR RtmRegHandle,
    INT_PTR DestHandle,
    BOOL Exclusive,
    BOOL LockDest
);

パラメーター

名前方向
RtmRegHandleINT_PTRin
DestHandleINT_PTRin
ExclusiveBOOLin
LockDestBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

RtmLockDestination = ctypes.windll.rtm.RtmLockDestination
RtmLockDestination.restype = wintypes.DWORD
RtmLockDestination.argtypes = [
    ctypes.c_ssize_t,  # RtmRegHandle : INT_PTR
    ctypes.c_ssize_t,  # DestHandle : INT_PTR
    wintypes.BOOL,  # Exclusive : BOOL
    wintypes.BOOL,  # LockDest : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rtm.dll')
RtmLockDestination = Fiddle::Function.new(
  lib['RtmLockDestination'],
  [
    Fiddle::TYPE_INTPTR_T,  # RtmRegHandle : INT_PTR
    Fiddle::TYPE_INTPTR_T,  # DestHandle : INT_PTR
    Fiddle::TYPE_INT,  # Exclusive : BOOL
    Fiddle::TYPE_INT,  # LockDest : BOOL
  ],
  -Fiddle::TYPE_INT)
#[link(name = "rtm")]
extern "system" {
    fn RtmLockDestination(
        RtmRegHandle: isize,  // INT_PTR
        DestHandle: isize,  // INT_PTR
        Exclusive: i32,  // BOOL
        LockDest: i32  // BOOL
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rtm.dll")]
public static extern uint RtmLockDestination(IntPtr RtmRegHandle, IntPtr DestHandle, bool Exclusive, bool LockDest);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtm_RtmLockDestination' -Namespace Win32 -PassThru
# $api::RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
#uselib "rtm.dll"
#func global RtmLockDestination "RtmLockDestination" sptr, sptr, sptr, sptr
; RtmLockDestination RtmRegHandle, DestHandle, Exclusive, LockDest   ; 戻り値は stat
; RtmRegHandle : INT_PTR -> "sptr"
; DestHandle : INT_PTR -> "sptr"
; Exclusive : BOOL -> "sptr"
; LockDest : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "rtm.dll"
#cfunc global RtmLockDestination "RtmLockDestination" sptr, sptr, int, int
; res = RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
; RtmRegHandle : INT_PTR -> "sptr"
; DestHandle : INT_PTR -> "sptr"
; Exclusive : BOOL -> "int"
; LockDest : BOOL -> "int"
; DWORD RtmLockDestination(INT_PTR RtmRegHandle, INT_PTR DestHandle, BOOL Exclusive, BOOL LockDest)
#uselib "rtm.dll"
#cfunc global RtmLockDestination "RtmLockDestination" intptr, intptr, int, int
; res = RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
; RtmRegHandle : INT_PTR -> "intptr"
; DestHandle : INT_PTR -> "intptr"
; Exclusive : BOOL -> "int"
; LockDest : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procRtmLockDestination = rtm.NewProc("RtmLockDestination")
)

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