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

MgmRegisterMProtocol

関数
マルチキャストグループマネージャーにプロトコルを登録する。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MgmRegisterMProtocol(
    ROUTING_PROTOCOL_CONFIG* prpiInfo,
    DWORD dwProtocolId,
    DWORD dwComponentId,
    HANDLE* phProtocol
);

パラメーター

名前方向説明
prpiInfoROUTING_PROTOCOL_CONFIG*inout登録するマルチキャストルーティングプロトコルの構成を格納したROUTING_PROTOCOL_CONFIG構造体へのポインタ。
dwProtocolIdDWORDin登録するルーティングプロトコルの識別子。
dwComponentIdDWORDinプロトコル内のコンポーネント識別子。
phProtocolHANDLE*inout登録後のプロトコルハンドルを受け取るポインタ。後続のMgm呼び出しに使用する。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MgmRegisterMProtocol(
    ROUTING_PROTOCOL_CONFIG* prpiInfo,
    DWORD dwProtocolId,
    DWORD dwComponentId,
    HANDLE* phProtocol
);
[DllImport("rtm.dll", ExactSpelling = true)]
static extern uint MgmRegisterMProtocol(
    IntPtr prpiInfo,   // ROUTING_PROTOCOL_CONFIG* in/out
    uint dwProtocolId,   // DWORD
    uint dwComponentId,   // DWORD
    IntPtr phProtocol   // HANDLE* in/out
);
<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function MgmRegisterMProtocol(
    prpiInfo As IntPtr,   ' ROUTING_PROTOCOL_CONFIG* in/out
    dwProtocolId As UInteger,   ' DWORD
    dwComponentId As UInteger,   ' DWORD
    phProtocol As IntPtr   ' HANDLE* in/out
) As UInteger
End Function
' prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out
' dwProtocolId : DWORD
' dwComponentId : DWORD
' phProtocol : HANDLE* in/out
Declare PtrSafe Function MgmRegisterMProtocol Lib "rtm" ( _
    ByVal prpiInfo As LongPtr, _
    ByVal dwProtocolId As Long, _
    ByVal dwComponentId As Long, _
    ByVal phProtocol As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MgmRegisterMProtocol = ctypes.windll.rtm.MgmRegisterMProtocol
MgmRegisterMProtocol.restype = wintypes.DWORD
MgmRegisterMProtocol.argtypes = [
    ctypes.c_void_p,  # prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out
    wintypes.DWORD,  # dwProtocolId : DWORD
    wintypes.DWORD,  # dwComponentId : DWORD
    ctypes.c_void_p,  # phProtocol : HANDLE* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procMgmRegisterMProtocol = rtm.NewProc("MgmRegisterMProtocol")
)

// prpiInfo (ROUTING_PROTOCOL_CONFIG* in/out), dwProtocolId (DWORD), dwComponentId (DWORD), phProtocol (HANDLE* in/out)
r1, _, err := procMgmRegisterMProtocol.Call(
	uintptr(prpiInfo),
	uintptr(dwProtocolId),
	uintptr(dwComponentId),
	uintptr(phProtocol),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MgmRegisterMProtocol(
  prpiInfo: Pointer;   // ROUTING_PROTOCOL_CONFIG* in/out
  dwProtocolId: DWORD;   // DWORD
  dwComponentId: DWORD;   // DWORD
  phProtocol: Pointer   // HANDLE* in/out
): DWORD; stdcall;
  external 'rtm.dll' name 'MgmRegisterMProtocol';
result := DllCall("rtm\MgmRegisterMProtocol"
    , "Ptr", prpiInfo   ; ROUTING_PROTOCOL_CONFIG* in/out
    , "UInt", dwProtocolId   ; DWORD
    , "UInt", dwComponentId   ; DWORD
    , "Ptr", phProtocol   ; HANDLE* in/out
    , "UInt")   ; return: DWORD
●MgmRegisterMProtocol(prpiInfo, dwProtocolId, dwComponentId, phProtocol) = DLL("rtm.dll", "dword MgmRegisterMProtocol(void*, dword, dword, void*)")
# 呼び出し: MgmRegisterMProtocol(prpiInfo, dwProtocolId, dwComponentId, phProtocol)
# prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out -> "void*"
# dwProtocolId : DWORD -> "dword"
# dwComponentId : DWORD -> "dword"
# phProtocol : HANDLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

foreign import stdcall safe "MgmRegisterMProtocol"
  c_MgmRegisterMProtocol :: Ptr () -> Word32 -> Word32 -> Ptr () -> IO Word32
-- prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out -> Ptr ()
-- dwProtocolId : DWORD -> Word32
-- dwComponentId : DWORD -> Word32
-- phProtocol : HANDLE* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mgmregistermprotocol =
  foreign "MgmRegisterMProtocol"
    ((ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out -> (ptr void) *)
(* dwProtocolId : DWORD -> uint32_t *)
(* dwComponentId : DWORD -> uint32_t *)
(* phProtocol : HANDLE* 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 ("MgmRegisterMProtocol" mgm-register-mprotocol :convention :stdcall) :uint32
  (prpi-info :pointer)   ; ROUTING_PROTOCOL_CONFIG* in/out
  (dw-protocol-id :uint32)   ; DWORD
  (dw-component-id :uint32)   ; DWORD
  (ph-protocol :pointer))   ; HANDLE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MgmRegisterMProtocol = Win32::API::More->new('rtm',
    'DWORD MgmRegisterMProtocol(LPVOID prpiInfo, DWORD dwProtocolId, DWORD dwComponentId, HANDLE phProtocol)');
# my $ret = $MgmRegisterMProtocol->Call($prpiInfo, $dwProtocolId, $dwComponentId, $phProtocol);
# prpiInfo : ROUTING_PROTOCOL_CONFIG* in/out -> LPVOID
# dwProtocolId : DWORD -> DWORD
# dwComponentId : DWORD -> DWORD
# phProtocol : HANDLE* in/out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型