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
dwProtocolIdDWORDin
dwComponentIdDWORDin
phProtocolHANDLE*inout

戻り値の型: 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)。