ホーム › NetworkManagement.Multicast › McastEnumerateScopes
McastEnumerateScopes
関数利用可能なマルチキャストアドレススコープを列挙する。
シグネチャ
// dhcpcsvc.dll
#include <windows.h>
DWORD McastEnumerateScopes(
WORD AddrFamily,
BOOL ReQuery,
MCAST_SCOPE_ENTRY* pScopeList,
DWORD* pScopeLen,
DWORD* pScopeCount
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| AddrFamily | WORD | in | 対象アドレスファミリ(AF_INET=2 / AF_INET6=23)。 |
| ReQuery | BOOL | in | TRUEでサーバーへ再問い合わせし、FALSEでキャッシュを使用する。 |
| pScopeList | MCAST_SCOPE_ENTRY* | inout | 列挙されたスコープ情報を受け取るMCAST_SCOPE_ENTRY配列。 |
| pScopeLen | DWORD* | inout | バッファ長を渡し、必要長を受け取る入出力ポインタ(バイト単位)。 |
| pScopeCount | DWORD* | inout | 返されたスコープ数を受け取る出力ポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// dhcpcsvc.dll
#include <windows.h>
DWORD McastEnumerateScopes(
WORD AddrFamily,
BOOL ReQuery,
MCAST_SCOPE_ENTRY* pScopeList,
DWORD* pScopeLen,
DWORD* pScopeCount
);[DllImport("dhcpcsvc.dll", ExactSpelling = true)]
static extern uint McastEnumerateScopes(
ushort AddrFamily, // WORD
bool ReQuery, // BOOL
IntPtr pScopeList, // MCAST_SCOPE_ENTRY* in/out
ref uint pScopeLen, // DWORD* in/out
ref uint pScopeCount // DWORD* in/out
);<DllImport("dhcpcsvc.dll", ExactSpelling:=True)>
Public Shared Function McastEnumerateScopes(
AddrFamily As UShort, ' WORD
ReQuery As Boolean, ' BOOL
pScopeList As IntPtr, ' MCAST_SCOPE_ENTRY* in/out
ByRef pScopeLen As UInteger, ' DWORD* in/out
ByRef pScopeCount As UInteger ' DWORD* in/out
) As UInteger
End Function' AddrFamily : WORD
' ReQuery : BOOL
' pScopeList : MCAST_SCOPE_ENTRY* in/out
' pScopeLen : DWORD* in/out
' pScopeCount : DWORD* in/out
Declare PtrSafe Function McastEnumerateScopes Lib "dhcpcsvc" ( _
ByVal AddrFamily As Integer, _
ByVal ReQuery As Long, _
ByVal pScopeList As LongPtr, _
ByRef pScopeLen As Long, _
ByRef pScopeCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
McastEnumerateScopes = ctypes.windll.dhcpcsvc.McastEnumerateScopes
McastEnumerateScopes.restype = wintypes.DWORD
McastEnumerateScopes.argtypes = [
ctypes.c_ushort, # AddrFamily : WORD
wintypes.BOOL, # ReQuery : BOOL
ctypes.c_void_p, # pScopeList : MCAST_SCOPE_ENTRY* in/out
ctypes.POINTER(wintypes.DWORD), # pScopeLen : DWORD* in/out
ctypes.POINTER(wintypes.DWORD), # pScopeCount : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dhcpcsvc.dll')
McastEnumerateScopes = Fiddle::Function.new(
lib['McastEnumerateScopes'],
[
-Fiddle::TYPE_SHORT, # AddrFamily : WORD
Fiddle::TYPE_INT, # ReQuery : BOOL
Fiddle::TYPE_VOIDP, # pScopeList : MCAST_SCOPE_ENTRY* in/out
Fiddle::TYPE_VOIDP, # pScopeLen : DWORD* in/out
Fiddle::TYPE_VOIDP, # pScopeCount : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "dhcpcsvc")]
extern "system" {
fn McastEnumerateScopes(
AddrFamily: u16, // WORD
ReQuery: i32, // BOOL
pScopeList: *mut MCAST_SCOPE_ENTRY, // MCAST_SCOPE_ENTRY* in/out
pScopeLen: *mut u32, // DWORD* in/out
pScopeCount: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dhcpcsvc.dll")]
public static extern uint McastEnumerateScopes(ushort AddrFamily, bool ReQuery, IntPtr pScopeList, ref uint pScopeLen, ref uint pScopeCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dhcpcsvc_McastEnumerateScopes' -Namespace Win32 -PassThru
# $api::McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)#uselib "dhcpcsvc.dll"
#func global McastEnumerateScopes "McastEnumerateScopes" sptr, sptr, sptr, sptr, sptr
; McastEnumerateScopes AddrFamily, ReQuery, varptr(pScopeList), varptr(pScopeLen), varptr(pScopeCount) ; 戻り値は stat
; AddrFamily : WORD -> "sptr"
; ReQuery : BOOL -> "sptr"
; pScopeList : MCAST_SCOPE_ENTRY* in/out -> "sptr"
; pScopeLen : DWORD* in/out -> "sptr"
; pScopeCount : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dhcpcsvc.dll" #cfunc global McastEnumerateScopes "McastEnumerateScopes" int, int, var, var, var ; res = McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount) ; AddrFamily : WORD -> "int" ; ReQuery : BOOL -> "int" ; pScopeList : MCAST_SCOPE_ENTRY* in/out -> "var" ; pScopeLen : DWORD* in/out -> "var" ; pScopeCount : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dhcpcsvc.dll" #cfunc global McastEnumerateScopes "McastEnumerateScopes" int, int, sptr, sptr, sptr ; res = McastEnumerateScopes(AddrFamily, ReQuery, varptr(pScopeList), varptr(pScopeLen), varptr(pScopeCount)) ; AddrFamily : WORD -> "int" ; ReQuery : BOOL -> "int" ; pScopeList : MCAST_SCOPE_ENTRY* in/out -> "sptr" ; pScopeLen : DWORD* in/out -> "sptr" ; pScopeCount : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD McastEnumerateScopes(WORD AddrFamily, BOOL ReQuery, MCAST_SCOPE_ENTRY* pScopeList, DWORD* pScopeLen, DWORD* pScopeCount) #uselib "dhcpcsvc.dll" #cfunc global McastEnumerateScopes "McastEnumerateScopes" int, int, var, var, var ; res = McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount) ; AddrFamily : WORD -> "int" ; ReQuery : BOOL -> "int" ; pScopeList : MCAST_SCOPE_ENTRY* in/out -> "var" ; pScopeLen : DWORD* in/out -> "var" ; pScopeCount : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD McastEnumerateScopes(WORD AddrFamily, BOOL ReQuery, MCAST_SCOPE_ENTRY* pScopeList, DWORD* pScopeLen, DWORD* pScopeCount) #uselib "dhcpcsvc.dll" #cfunc global McastEnumerateScopes "McastEnumerateScopes" int, int, intptr, intptr, intptr ; res = McastEnumerateScopes(AddrFamily, ReQuery, varptr(pScopeList), varptr(pScopeLen), varptr(pScopeCount)) ; AddrFamily : WORD -> "int" ; ReQuery : BOOL -> "int" ; pScopeList : MCAST_SCOPE_ENTRY* in/out -> "intptr" ; pScopeLen : DWORD* in/out -> "intptr" ; pScopeCount : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpcsvc = windows.NewLazySystemDLL("dhcpcsvc.dll")
procMcastEnumerateScopes = dhcpcsvc.NewProc("McastEnumerateScopes")
)
// AddrFamily (WORD), ReQuery (BOOL), pScopeList (MCAST_SCOPE_ENTRY* in/out), pScopeLen (DWORD* in/out), pScopeCount (DWORD* in/out)
r1, _, err := procMcastEnumerateScopes.Call(
uintptr(AddrFamily),
uintptr(ReQuery),
uintptr(pScopeList),
uintptr(pScopeLen),
uintptr(pScopeCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction McastEnumerateScopes(
AddrFamily: Word; // WORD
ReQuery: BOOL; // BOOL
pScopeList: Pointer; // MCAST_SCOPE_ENTRY* in/out
pScopeLen: Pointer; // DWORD* in/out
pScopeCount: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'dhcpcsvc.dll' name 'McastEnumerateScopes';result := DllCall("dhcpcsvc\McastEnumerateScopes"
, "UShort", AddrFamily ; WORD
, "Int", ReQuery ; BOOL
, "Ptr", pScopeList ; MCAST_SCOPE_ENTRY* in/out
, "Ptr", pScopeLen ; DWORD* in/out
, "Ptr", pScopeCount ; DWORD* in/out
, "UInt") ; return: DWORD●McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount) = DLL("dhcpcsvc.dll", "dword McastEnumerateScopes(int, bool, void*, void*, void*)")
# 呼び出し: McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)
# AddrFamily : WORD -> "int"
# ReQuery : BOOL -> "bool"
# pScopeList : MCAST_SCOPE_ENTRY* in/out -> "void*"
# pScopeLen : DWORD* in/out -> "void*"
# pScopeCount : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dhcpcsvc" fn McastEnumerateScopes(
AddrFamily: u16, // WORD
ReQuery: i32, // BOOL
pScopeList: [*c]MCAST_SCOPE_ENTRY, // MCAST_SCOPE_ENTRY* in/out
pScopeLen: [*c]u32, // DWORD* in/out
pScopeCount: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;proc McastEnumerateScopes(
AddrFamily: uint16, # WORD
ReQuery: int32, # BOOL
pScopeList: ptr MCAST_SCOPE_ENTRY, # MCAST_SCOPE_ENTRY* in/out
pScopeLen: ptr uint32, # DWORD* in/out
pScopeCount: ptr uint32 # DWORD* in/out
): uint32 {.importc: "McastEnumerateScopes", stdcall, dynlib: "dhcpcsvc.dll".}pragma(lib, "dhcpcsvc");
extern(Windows)
uint McastEnumerateScopes(
ushort AddrFamily, // WORD
int ReQuery, // BOOL
MCAST_SCOPE_ENTRY* pScopeList, // MCAST_SCOPE_ENTRY* in/out
uint* pScopeLen, // DWORD* in/out
uint* pScopeCount // DWORD* in/out
);ccall((:McastEnumerateScopes, "dhcpcsvc.dll"), stdcall, UInt32,
(UInt16, Int32, Ptr{MCAST_SCOPE_ENTRY}, Ptr{UInt32}, Ptr{UInt32}),
AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)
# AddrFamily : WORD -> UInt16
# ReQuery : BOOL -> Int32
# pScopeList : MCAST_SCOPE_ENTRY* in/out -> Ptr{MCAST_SCOPE_ENTRY}
# pScopeLen : DWORD* in/out -> Ptr{UInt32}
# pScopeCount : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t McastEnumerateScopes(
uint16_t AddrFamily,
int32_t ReQuery,
void* pScopeList,
uint32_t* pScopeLen,
uint32_t* pScopeCount);
]]
local dhcpcsvc = ffi.load("dhcpcsvc")
-- dhcpcsvc.McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)
-- AddrFamily : WORD
-- ReQuery : BOOL
-- pScopeList : MCAST_SCOPE_ENTRY* in/out
-- pScopeLen : DWORD* in/out
-- pScopeCount : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dhcpcsvc.dll');
const McastEnumerateScopes = lib.func('__stdcall', 'McastEnumerateScopes', 'uint32_t', ['uint16_t', 'int32_t', 'void *', 'uint32_t *', 'uint32_t *']);
// McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)
// AddrFamily : WORD -> 'uint16_t'
// ReQuery : BOOL -> 'int32_t'
// pScopeList : MCAST_SCOPE_ENTRY* in/out -> 'void *'
// pScopeLen : DWORD* in/out -> 'uint32_t *'
// pScopeCount : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dhcpcsvc.dll", {
McastEnumerateScopes: { parameters: ["u16", "i32", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount)
// AddrFamily : WORD -> "u16"
// ReQuery : BOOL -> "i32"
// pScopeList : MCAST_SCOPE_ENTRY* in/out -> "pointer"
// pScopeLen : DWORD* in/out -> "pointer"
// pScopeCount : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t McastEnumerateScopes(
uint16_t AddrFamily,
int32_t ReQuery,
void* pScopeList,
uint32_t* pScopeLen,
uint32_t* pScopeCount);
C, "dhcpcsvc.dll");
// $ffi->McastEnumerateScopes(AddrFamily, ReQuery, pScopeList, pScopeLen, pScopeCount);
// AddrFamily : WORD
// ReQuery : BOOL
// pScopeList : MCAST_SCOPE_ENTRY* in/out
// pScopeLen : DWORD* in/out
// pScopeCount : DWORD* 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 Dhcpcsvc extends StdCallLibrary {
Dhcpcsvc INSTANCE = Native.load("dhcpcsvc", Dhcpcsvc.class);
int McastEnumerateScopes(
short AddrFamily, // WORD
boolean ReQuery, // BOOL
Pointer pScopeList, // MCAST_SCOPE_ENTRY* in/out
IntByReference pScopeLen, // DWORD* in/out
IntByReference pScopeCount // DWORD* in/out
);
}@[Link("dhcpcsvc")]
lib Libdhcpcsvc
fun McastEnumerateScopes = McastEnumerateScopes(
AddrFamily : UInt16, # WORD
ReQuery : Int32, # BOOL
pScopeList : MCAST_SCOPE_ENTRY*, # MCAST_SCOPE_ENTRY* in/out
pScopeLen : UInt32*, # DWORD* in/out
pScopeCount : UInt32* # DWORD* 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 McastEnumerateScopesNative = Uint32 Function(Uint16, Int32, Pointer<Void>, Pointer<Uint32>, Pointer<Uint32>);
typedef McastEnumerateScopesDart = int Function(int, int, Pointer<Void>, Pointer<Uint32>, Pointer<Uint32>);
final McastEnumerateScopes = DynamicLibrary.open('dhcpcsvc.dll')
.lookupFunction<McastEnumerateScopesNative, McastEnumerateScopesDart>('McastEnumerateScopes');
// AddrFamily : WORD -> Uint16
// ReQuery : BOOL -> Int32
// pScopeList : MCAST_SCOPE_ENTRY* in/out -> Pointer<Void>
// pScopeLen : DWORD* in/out -> Pointer<Uint32>
// pScopeCount : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function McastEnumerateScopes(
AddrFamily: Word; // WORD
ReQuery: BOOL; // BOOL
pScopeList: Pointer; // MCAST_SCOPE_ENTRY* in/out
pScopeLen: Pointer; // DWORD* in/out
pScopeCount: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'dhcpcsvc.dll' name 'McastEnumerateScopes';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "McastEnumerateScopes"
c_McastEnumerateScopes :: Word16 -> CInt -> Ptr () -> Ptr Word32 -> Ptr Word32 -> IO Word32
-- AddrFamily : WORD -> Word16
-- ReQuery : BOOL -> CInt
-- pScopeList : MCAST_SCOPE_ENTRY* in/out -> Ptr ()
-- pScopeLen : DWORD* in/out -> Ptr Word32
-- pScopeCount : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mcastenumeratescopes =
foreign "McastEnumerateScopes"
(uint16_t @-> int32_t @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* AddrFamily : WORD -> uint16_t *)
(* ReQuery : BOOL -> int32_t *)
(* pScopeList : MCAST_SCOPE_ENTRY* in/out -> (ptr void) *)
(* pScopeLen : DWORD* in/out -> (ptr uint32_t) *)
(* pScopeCount : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dhcpcsvc (t "dhcpcsvc.dll"))
(cffi:use-foreign-library dhcpcsvc)
(cffi:defcfun ("McastEnumerateScopes" mcast-enumerate-scopes :convention :stdcall) :uint32
(addr-family :uint16) ; WORD
(re-query :int32) ; BOOL
(p-scope-list :pointer) ; MCAST_SCOPE_ENTRY* in/out
(p-scope-len :pointer) ; DWORD* in/out
(p-scope-count :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $McastEnumerateScopes = Win32::API::More->new('dhcpcsvc',
'DWORD McastEnumerateScopes(WORD AddrFamily, BOOL ReQuery, LPVOID pScopeList, LPVOID pScopeLen, LPVOID pScopeCount)');
# my $ret = $McastEnumerateScopes->Call($AddrFamily, $ReQuery, $pScopeList, $pScopeLen, $pScopeCount);
# AddrFamily : WORD -> WORD
# ReQuery : BOOL -> BOOL
# pScopeList : MCAST_SCOPE_ENTRY* in/out -> LPVOID
# pScopeLen : DWORD* in/out -> LPVOID
# pScopeCount : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型