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

MgmReleaseInterfaceOwnership

関数
指定インターフェイスのマルチキャスト所有権を解放する。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MgmReleaseInterfaceOwnership(
    HANDLE hProtocol,
    DWORD dwIfIndex,
    DWORD dwIfNextHopAddr
);

パラメーター

名前方向説明
hProtocolHANDLEinMgmRegisterMProtocolで取得したプロトコルハンドル。
dwIfIndexDWORDin所有権を解放する対象インターフェイスのインデックス。
dwIfNextHopAddrDWORDinポイントツーマルチポイント時のネクストホップIPアドレス(ネットワークバイト順)。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MgmReleaseInterfaceOwnership = ctypes.windll.rtm.MgmReleaseInterfaceOwnership
MgmReleaseInterfaceOwnership.restype = wintypes.DWORD
MgmReleaseInterfaceOwnership.argtypes = [
    wintypes.HANDLE,  # hProtocol : HANDLE
    wintypes.DWORD,  # dwIfIndex : DWORD
    wintypes.DWORD,  # dwIfNextHopAddr : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procMgmReleaseInterfaceOwnership = rtm.NewProc("MgmReleaseInterfaceOwnership")
)

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

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

foreign import stdcall safe "MgmReleaseInterfaceOwnership"
  c_MgmReleaseInterfaceOwnership :: Ptr () -> Word32 -> Word32 -> IO Word32
-- hProtocol : HANDLE -> Ptr ()
-- dwIfIndex : DWORD -> Word32
-- dwIfNextHopAddr : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mgmreleaseinterfaceownership =
  foreign "MgmReleaseInterfaceOwnership"
    ((ptr void) @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* hProtocol : HANDLE -> (ptr void) *)
(* dwIfIndex : DWORD -> uint32_t *)
(* dwIfNextHopAddr : 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 ("MgmReleaseInterfaceOwnership" mgm-release-interface-ownership :convention :stdcall) :uint32
  (h-protocol :pointer)   ; HANDLE
  (dw-if-index :uint32)   ; DWORD
  (dw-if-next-hop-addr :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MgmReleaseInterfaceOwnership = Win32::API::More->new('rtm',
    'DWORD MgmReleaseInterfaceOwnership(HANDLE hProtocol, DWORD dwIfIndex, DWORD dwIfNextHopAddr)');
# my $ret = $MgmReleaseInterfaceOwnership->Call($hProtocol, $dwIfIndex, $dwIfNextHopAddr);
# hProtocol : HANDLE -> HANDLE
# dwIfIndex : DWORD -> DWORD
# dwIfNextHopAddr : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。