ホーム › NetworkManagement.Rras › RtmLockDestination
RtmLockDestination
関数ルーティングの宛先を排他または共有ロックする。
シグネチャ
// rtm.dll
#include <windows.h>
DWORD RtmLockDestination(
INT_PTR RtmRegHandle,
INT_PTR DestHandle,
BOOL Exclusive,
BOOL LockDest
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| RtmRegHandle | INT_PTR | in | RtmRegisterEntityで取得したRTM登録ハンドル。 |
| DestHandle | INT_PTR | in | ロック/アンロックする対象宛先のハンドル。 |
| Exclusive | BOOL | in | TRUEなら排他(書き込み)ロック、FALSEなら共有(読み取り)ロックを取得する。 |
| LockDest | BOOL | in | TRUEならロックを取得し、FALSEならロックを解放する。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "rtm" fn RtmLockDestination(
RtmRegHandle: isize, // INT_PTR
DestHandle: isize, // INT_PTR
Exclusive: i32, // BOOL
LockDest: i32 // BOOL
) callconv(std.os.windows.WINAPI) u32;proc RtmLockDestination(
RtmRegHandle: int, # INT_PTR
DestHandle: int, # INT_PTR
Exclusive: int32, # BOOL
LockDest: int32 # BOOL
): uint32 {.importc: "RtmLockDestination", stdcall, dynlib: "rtm.dll".}pragma(lib, "rtm");
extern(Windows)
uint RtmLockDestination(
ptrdiff_t RtmRegHandle, // INT_PTR
ptrdiff_t DestHandle, // INT_PTR
int Exclusive, // BOOL
int LockDest // BOOL
);ccall((:RtmLockDestination, "rtm.dll"), stdcall, UInt32,
(Int, Int, Int32, Int32),
RtmRegHandle, DestHandle, Exclusive, LockDest)
# RtmRegHandle : INT_PTR -> Int
# DestHandle : INT_PTR -> Int
# Exclusive : BOOL -> Int32
# LockDest : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RtmLockDestination(
intptr_t RtmRegHandle,
intptr_t DestHandle,
int32_t Exclusive,
int32_t LockDest);
]]
local rtm = ffi.load("rtm")
-- rtm.RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
-- RtmRegHandle : INT_PTR
-- DestHandle : INT_PTR
-- Exclusive : BOOL
-- LockDest : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('rtm.dll');
const RtmLockDestination = lib.func('__stdcall', 'RtmLockDestination', 'uint32_t', ['intptr_t', 'intptr_t', 'int32_t', 'int32_t']);
// RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
// RtmRegHandle : INT_PTR -> 'intptr_t'
// DestHandle : INT_PTR -> 'intptr_t'
// Exclusive : BOOL -> 'int32_t'
// LockDest : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("rtm.dll", {
RtmLockDestination: { parameters: ["isize", "isize", "i32", "i32"], result: "u32" },
});
// lib.symbols.RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest)
// RtmRegHandle : INT_PTR -> "isize"
// DestHandle : INT_PTR -> "isize"
// Exclusive : BOOL -> "i32"
// LockDest : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RtmLockDestination(
intptr_t RtmRegHandle,
intptr_t DestHandle,
int32_t Exclusive,
int32_t LockDest);
C, "rtm.dll");
// $ffi->RtmLockDestination(RtmRegHandle, DestHandle, Exclusive, LockDest);
// RtmRegHandle : INT_PTR
// DestHandle : INT_PTR
// Exclusive : BOOL
// LockDest : BOOL
// 構造体/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 RtmLockDestination(
long RtmRegHandle, // INT_PTR
long DestHandle, // INT_PTR
boolean Exclusive, // BOOL
boolean LockDest // BOOL
);
}@[Link("rtm")]
lib Librtm
fun RtmLockDestination = RtmLockDestination(
RtmRegHandle : LibC::SSizeT, # INT_PTR
DestHandle : LibC::SSizeT, # INT_PTR
Exclusive : Int32, # BOOL
LockDest : Int32 # BOOL
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtmLockDestinationNative = Uint32 Function(IntPtr, IntPtr, Int32, Int32);
typedef RtmLockDestinationDart = int Function(int, int, int, int);
final RtmLockDestination = DynamicLibrary.open('rtm.dll')
.lookupFunction<RtmLockDestinationNative, RtmLockDestinationDart>('RtmLockDestination');
// RtmRegHandle : INT_PTR -> IntPtr
// DestHandle : INT_PTR -> IntPtr
// Exclusive : BOOL -> Int32
// LockDest : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtmLockDestination(
RtmRegHandle: NativeInt; // INT_PTR
DestHandle: NativeInt; // INT_PTR
Exclusive: BOOL; // BOOL
LockDest: BOOL // BOOL
): DWORD; stdcall;
external 'rtm.dll' name 'RtmLockDestination';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtmLockDestination"
c_RtmLockDestination :: CIntPtr -> CIntPtr -> CInt -> CInt -> IO Word32
-- RtmRegHandle : INT_PTR -> CIntPtr
-- DestHandle : INT_PTR -> CIntPtr
-- Exclusive : BOOL -> CInt
-- LockDest : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtmlockdestination =
foreign "RtmLockDestination"
(intptr_t @-> intptr_t @-> int32_t @-> int32_t @-> returning uint32_t)
(* RtmRegHandle : INT_PTR -> intptr_t *)
(* DestHandle : INT_PTR -> intptr_t *)
(* Exclusive : BOOL -> int32_t *)
(* LockDest : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rtm (t "rtm.dll"))
(cffi:use-foreign-library rtm)
(cffi:defcfun ("RtmLockDestination" rtm-lock-destination :convention :stdcall) :uint32
(rtm-reg-handle :int64) ; INT_PTR
(dest-handle :int64) ; INT_PTR
(exclusive :int32) ; BOOL
(lock-dest :int32)) ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtmLockDestination = Win32::API::More->new('rtm',
'DWORD RtmLockDestination(LPARAM RtmRegHandle, LPARAM DestHandle, BOOL Exclusive, BOOL LockDest)');
# my $ret = $RtmLockDestination->Call($RtmRegHandle, $DestHandle, $Exclusive, $LockDest);
# RtmRegHandle : INT_PTR -> LPARAM
# DestHandle : INT_PTR -> LPARAM
# Exclusive : BOOL -> BOOL
# LockDest : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。