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

MprConfigInterfaceGetInfo

関数
ルーター構成内のインターフェイスの情報を取得する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprConfigInterfaceGetInfo(
    HANDLE hMprConfig,
    HANDLE hRouterInterface,
    DWORD dwLevel,
    BYTE** lplpBuffer,
    DWORD* lpdwBufferSize
);

パラメーター

名前方向説明
hMprConfigHANDLEinMprConfigServerConnectで取得した構成ハンドル。
hRouterInterfaceHANDLEin情報を取得する対象インターフェイスのハンドル。
dwLevelDWORDin返される情報のレベルを示す値。
lplpBufferBYTE**inoutインターフェイス情報を格納したバッファへのポインタを受け取る。MprConfigBufferFreeで解放する。
lpdwBufferSizeDWORD*out返されたバッファのサイズ(バイト単位)を受け取るポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprConfigInterfaceGetInfo(
    HANDLE hMprConfig,
    HANDLE hRouterInterface,
    DWORD dwLevel,
    BYTE** lplpBuffer,
    DWORD* lpdwBufferSize
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprConfigInterfaceGetInfo(
    IntPtr hMprConfig,   // HANDLE
    IntPtr hRouterInterface,   // HANDLE
    uint dwLevel,   // DWORD
    IntPtr lplpBuffer,   // BYTE** in/out
    out uint lpdwBufferSize   // DWORD* out
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprConfigInterfaceGetInfo(
    hMprConfig As IntPtr,   ' HANDLE
    hRouterInterface As IntPtr,   ' HANDLE
    dwLevel As UInteger,   ' DWORD
    lplpBuffer As IntPtr,   ' BYTE** in/out
    <Out> ByRef lpdwBufferSize As UInteger   ' DWORD* out
) As UInteger
End Function
' hMprConfig : HANDLE
' hRouterInterface : HANDLE
' dwLevel : DWORD
' lplpBuffer : BYTE** in/out
' lpdwBufferSize : DWORD* out
Declare PtrSafe Function MprConfigInterfaceGetInfo Lib "mprapi" ( _
    ByVal hMprConfig As LongPtr, _
    ByVal hRouterInterface As LongPtr, _
    ByVal dwLevel As Long, _
    ByVal lplpBuffer As LongPtr, _
    ByRef lpdwBufferSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprConfigInterfaceGetInfo = ctypes.windll.mprapi.MprConfigInterfaceGetInfo
MprConfigInterfaceGetInfo.restype = wintypes.DWORD
MprConfigInterfaceGetInfo.argtypes = [
    wintypes.HANDLE,  # hMprConfig : HANDLE
    wintypes.HANDLE,  # hRouterInterface : HANDLE
    wintypes.DWORD,  # dwLevel : DWORD
    ctypes.c_void_p,  # lplpBuffer : BYTE** in/out
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufferSize : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprConfigInterfaceGetInfo = mprapi.NewProc("MprConfigInterfaceGetInfo")
)

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

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

typedef MprConfigInterfaceGetInfoNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Uint8>, Pointer<Uint32>);
typedef MprConfigInterfaceGetInfoDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Uint8>, Pointer<Uint32>);
final MprConfigInterfaceGetInfo = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprConfigInterfaceGetInfoNative, MprConfigInterfaceGetInfoDart>('MprConfigInterfaceGetInfo');
// hMprConfig : HANDLE -> Pointer<Void>
// hRouterInterface : HANDLE -> Pointer<Void>
// dwLevel : DWORD -> Uint32
// lplpBuffer : BYTE** in/out -> Pointer<Uint8>
// lpdwBufferSize : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprConfigInterfaceGetInfo(
  hMprConfig: THandle;   // HANDLE
  hRouterInterface: THandle;   // HANDLE
  dwLevel: DWORD;   // DWORD
  lplpBuffer: Pointer;   // BYTE** in/out
  lpdwBufferSize: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprConfigInterfaceGetInfo';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprConfigInterfaceGetInfo"
  c_MprConfigInterfaceGetInfo :: Ptr () -> Ptr () -> Word32 -> Ptr Word8 -> Ptr Word32 -> IO Word32
-- hMprConfig : HANDLE -> Ptr ()
-- hRouterInterface : HANDLE -> Ptr ()
-- dwLevel : DWORD -> Word32
-- lplpBuffer : BYTE** in/out -> Ptr Word8
-- lpdwBufferSize : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mprconfiginterfacegetinfo =
  foreign "MprConfigInterfaceGetInfo"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint8_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* hMprConfig : HANDLE -> (ptr void) *)
(* hRouterInterface : HANDLE -> (ptr void) *)
(* dwLevel : DWORD -> uint32_t *)
(* lplpBuffer : BYTE** in/out -> (ptr uint8_t) *)
(* lpdwBufferSize : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprConfigInterfaceGetInfo" mpr-config-interface-get-info :convention :stdcall) :uint32
  (h-mpr-config :pointer)   ; HANDLE
  (h-router-interface :pointer)   ; HANDLE
  (dw-level :uint32)   ; DWORD
  (lplp-buffer :pointer)   ; BYTE** in/out
  (lpdw-buffer-size :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprConfigInterfaceGetInfo = Win32::API::More->new('MPRAPI',
    'DWORD MprConfigInterfaceGetInfo(HANDLE hMprConfig, HANDLE hRouterInterface, DWORD dwLevel, LPVOID lplpBuffer, LPVOID lpdwBufferSize)');
# my $ret = $MprConfigInterfaceGetInfo->Call($hMprConfig, $hRouterInterface, $dwLevel, $lplpBuffer, $lpdwBufferSize);
# hMprConfig : HANDLE -> HANDLE
# hRouterInterface : HANDLE -> HANDLE
# dwLevel : DWORD -> DWORD
# lplpBuffer : BYTE** in/out -> LPVOID
# lpdwBufferSize : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。