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

RtmBlockMethods

関数
指定対象に対するメソッド呼び出しをブロックまたは解除する。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD RtmBlockMethods(
    INT_PTR RtmRegHandle,
    HANDLE TargetHandle,
    BYTE TargetType,
    DWORD BlockingFlag
);

パラメーター

名前方向説明
RtmRegHandleINT_PTRinRtmRegisterEntityで取得したRTM登録ハンドル。
TargetHandleHANDLEinメソッド呼び出しをブロックする対象のハンドル。
TargetTypeBYTEinTargetHandleの種類を示すバイト値(エンティティ/宛先/ルート等)。
BlockingFlagDWORDinブロック動作を制御するフラグ(ブロック/ブロック解除等)。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RtmBlockMethods(
    INT_PTR RtmRegHandle,
    HANDLE TargetHandle,
    BYTE TargetType,
    DWORD BlockingFlag
);
[DllImport("rtm.dll", ExactSpelling = true)]
static extern uint RtmBlockMethods(
    IntPtr RtmRegHandle,   // INT_PTR
    IntPtr TargetHandle,   // HANDLE
    byte TargetType,   // BYTE
    uint BlockingFlag   // DWORD
);
<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function RtmBlockMethods(
    RtmRegHandle As IntPtr,   ' INT_PTR
    TargetHandle As IntPtr,   ' HANDLE
    TargetType As Byte,   ' BYTE
    BlockingFlag As UInteger   ' DWORD
) As UInteger
End Function
' RtmRegHandle : INT_PTR
' TargetHandle : HANDLE
' TargetType : BYTE
' BlockingFlag : DWORD
Declare PtrSafe Function RtmBlockMethods Lib "rtm" ( _
    ByVal RtmRegHandle As LongPtr, _
    ByVal TargetHandle As LongPtr, _
    ByVal TargetType As Byte, _
    ByVal BlockingFlag As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtmBlockMethods = ctypes.windll.rtm.RtmBlockMethods
RtmBlockMethods.restype = wintypes.DWORD
RtmBlockMethods.argtypes = [
    ctypes.c_ssize_t,  # RtmRegHandle : INT_PTR
    wintypes.HANDLE,  # TargetHandle : HANDLE
    ctypes.c_ubyte,  # TargetType : BYTE
    wintypes.DWORD,  # BlockingFlag : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procRtmBlockMethods = rtm.NewProc("RtmBlockMethods")
)

// RtmRegHandle (INT_PTR), TargetHandle (HANDLE), TargetType (BYTE), BlockingFlag (DWORD)
r1, _, err := procRtmBlockMethods.Call(
	uintptr(RtmRegHandle),
	uintptr(TargetHandle),
	uintptr(TargetType),
	uintptr(BlockingFlag),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RtmBlockMethods(
  RtmRegHandle: NativeInt;   // INT_PTR
  TargetHandle: THandle;   // HANDLE
  TargetType: Byte;   // BYTE
  BlockingFlag: DWORD   // DWORD
): DWORD; stdcall;
  external 'rtm.dll' name 'RtmBlockMethods';
result := DllCall("rtm\RtmBlockMethods"
    , "Ptr", RtmRegHandle   ; INT_PTR
    , "Ptr", TargetHandle   ; HANDLE
    , "UChar", TargetType   ; BYTE
    , "UInt", BlockingFlag   ; DWORD
    , "UInt")   ; return: DWORD
●RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag) = DLL("rtm.dll", "dword RtmBlockMethods(int, void*, byte, dword)")
# 呼び出し: RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag)
# RtmRegHandle : INT_PTR -> "int"
# TargetHandle : HANDLE -> "void*"
# TargetType : BYTE -> "byte"
# BlockingFlag : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "rtm" fn RtmBlockMethods(
    RtmRegHandle: isize, // INT_PTR
    TargetHandle: ?*anyopaque, // HANDLE
    TargetType: u8, // BYTE
    BlockingFlag: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc RtmBlockMethods(
    RtmRegHandle: int,  # INT_PTR
    TargetHandle: pointer,  # HANDLE
    TargetType: uint8,  # BYTE
    BlockingFlag: uint32  # DWORD
): uint32 {.importc: "RtmBlockMethods", stdcall, dynlib: "rtm.dll".}
pragma(lib, "rtm");
extern(Windows)
uint RtmBlockMethods(
    ptrdiff_t RtmRegHandle,   // INT_PTR
    void* TargetHandle,   // HANDLE
    ubyte TargetType,   // BYTE
    uint BlockingFlag   // DWORD
);
ccall((:RtmBlockMethods, "rtm.dll"), stdcall, UInt32,
      (Int, Ptr{Cvoid}, UInt8, UInt32),
      RtmRegHandle, TargetHandle, TargetType, BlockingFlag)
# RtmRegHandle : INT_PTR -> Int
# TargetHandle : HANDLE -> Ptr{Cvoid}
# TargetType : BYTE -> UInt8
# BlockingFlag : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t RtmBlockMethods(
    intptr_t RtmRegHandle,
    void* TargetHandle,
    uint8_t TargetType,
    uint32_t BlockingFlag);
]]
local rtm = ffi.load("rtm")
-- rtm.RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag)
-- RtmRegHandle : INT_PTR
-- TargetHandle : HANDLE
-- TargetType : BYTE
-- BlockingFlag : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('rtm.dll');
const RtmBlockMethods = lib.func('__stdcall', 'RtmBlockMethods', 'uint32_t', ['intptr_t', 'void *', 'uint8_t', 'uint32_t']);
// RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag)
// RtmRegHandle : INT_PTR -> 'intptr_t'
// TargetHandle : HANDLE -> 'void *'
// TargetType : BYTE -> 'uint8_t'
// BlockingFlag : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("rtm.dll", {
  RtmBlockMethods: { parameters: ["isize", "pointer", "u8", "u32"], result: "u32" },
});
// lib.symbols.RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag)
// RtmRegHandle : INT_PTR -> "isize"
// TargetHandle : HANDLE -> "pointer"
// TargetType : BYTE -> "u8"
// BlockingFlag : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t RtmBlockMethods(
    intptr_t RtmRegHandle,
    void* TargetHandle,
    uint8_t TargetType,
    uint32_t BlockingFlag);
C, "rtm.dll");
// $ffi->RtmBlockMethods(RtmRegHandle, TargetHandle, TargetType, BlockingFlag);
// RtmRegHandle : INT_PTR
// TargetHandle : HANDLE
// TargetType : BYTE
// BlockingFlag : DWORD
// 構造体/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 RtmBlockMethods(
        long RtmRegHandle,   // INT_PTR
        Pointer TargetHandle,   // HANDLE
        byte TargetType,   // BYTE
        int BlockingFlag   // DWORD
    );
}
@[Link("rtm")]
lib Librtm
  fun RtmBlockMethods = RtmBlockMethods(
    RtmRegHandle : LibC::SSizeT,   # INT_PTR
    TargetHandle : Void*,   # HANDLE
    TargetType : UInt8,   # BYTE
    BlockingFlag : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RtmBlockMethodsNative = Uint32 Function(IntPtr, Pointer<Void>, Uint8, Uint32);
typedef RtmBlockMethodsDart = int Function(int, Pointer<Void>, int, int);
final RtmBlockMethods = DynamicLibrary.open('rtm.dll')
    .lookupFunction<RtmBlockMethodsNative, RtmBlockMethodsDart>('RtmBlockMethods');
// RtmRegHandle : INT_PTR -> IntPtr
// TargetHandle : HANDLE -> Pointer<Void>
// TargetType : BYTE -> Uint8
// BlockingFlag : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RtmBlockMethods(
  RtmRegHandle: NativeInt;   // INT_PTR
  TargetHandle: THandle;   // HANDLE
  TargetType: Byte;   // BYTE
  BlockingFlag: DWORD   // DWORD
): DWORD; stdcall;
  external 'rtm.dll' name 'RtmBlockMethods';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RtmBlockMethods"
  c_RtmBlockMethods :: CIntPtr -> Ptr () -> Word8 -> Word32 -> IO Word32
-- RtmRegHandle : INT_PTR -> CIntPtr
-- TargetHandle : HANDLE -> Ptr ()
-- TargetType : BYTE -> Word8
-- BlockingFlag : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rtmblockmethods =
  foreign "RtmBlockMethods"
    (intptr_t @-> (ptr void) @-> uint8_t @-> uint32_t @-> returning uint32_t)
(* RtmRegHandle : INT_PTR -> intptr_t *)
(* TargetHandle : HANDLE -> (ptr void) *)
(* TargetType : BYTE -> uint8_t *)
(* BlockingFlag : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rtm (t "rtm.dll"))
(cffi:use-foreign-library rtm)

(cffi:defcfun ("RtmBlockMethods" rtm-block-methods :convention :stdcall) :uint32
  (rtm-reg-handle :int64)   ; INT_PTR
  (target-handle :pointer)   ; HANDLE
  (target-type :uint8)   ; BYTE
  (blocking-flag :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RtmBlockMethods = Win32::API::More->new('rtm',
    'DWORD RtmBlockMethods(LPARAM RtmRegHandle, HANDLE TargetHandle, BYTE TargetType, DWORD BlockingFlag)');
# my $ret = $RtmBlockMethods->Call($RtmRegHandle, $TargetHandle, $TargetType, $BlockingFlag);
# RtmRegHandle : INT_PTR -> LPARAM
# TargetHandle : HANDLE -> HANDLE
# TargetType : BYTE -> BYTE
# BlockingFlag : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。