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

MprAdminMIBEntryCreate

関数
ルーティングプロトコルのMIBエントリを作成する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprAdminMIBEntryCreate(
    INT_PTR hMibServer,
    DWORD dwPid,
    DWORD dwRoutingPid,
    void* lpEntry,
    DWORD dwEntrySize
);

パラメーター

名前方向説明
hMibServerINT_PTRinMprAdminMIBServerConnectで取得したMIBサーバー接続ハンドル。
dwPidDWORDinエントリを作成するルーティングプロトコルの識別子。
dwRoutingPidDWORDinルーティングサブプロトコル(IP/IPX)の識別子。
lpEntryvoid*in作成するMIBエントリのデータを格納したバッファへのポインタ。
dwEntrySizeDWORDinlpEntryが指すバッファのサイズ(バイト単位)。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprAdminMIBEntryCreate(
    INT_PTR hMibServer,
    DWORD dwPid,
    DWORD dwRoutingPid,
    void* lpEntry,
    DWORD dwEntrySize
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprAdminMIBEntryCreate(
    IntPtr hMibServer,   // INT_PTR
    uint dwPid,   // DWORD
    uint dwRoutingPid,   // DWORD
    IntPtr lpEntry,   // void*
    uint dwEntrySize   // DWORD
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprAdminMIBEntryCreate(
    hMibServer As IntPtr,   ' INT_PTR
    dwPid As UInteger,   ' DWORD
    dwRoutingPid As UInteger,   ' DWORD
    lpEntry As IntPtr,   ' void*
    dwEntrySize As UInteger   ' DWORD
) As UInteger
End Function
' hMibServer : INT_PTR
' dwPid : DWORD
' dwRoutingPid : DWORD
' lpEntry : void*
' dwEntrySize : DWORD
Declare PtrSafe Function MprAdminMIBEntryCreate Lib "mprapi" ( _
    ByVal hMibServer As LongPtr, _
    ByVal dwPid As Long, _
    ByVal dwRoutingPid As Long, _
    ByVal lpEntry As LongPtr, _
    ByVal dwEntrySize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprAdminMIBEntryCreate = ctypes.windll.mprapi.MprAdminMIBEntryCreate
MprAdminMIBEntryCreate.restype = wintypes.DWORD
MprAdminMIBEntryCreate.argtypes = [
    ctypes.c_ssize_t,  # hMibServer : INT_PTR
    wintypes.DWORD,  # dwPid : DWORD
    wintypes.DWORD,  # dwRoutingPid : DWORD
    ctypes.POINTER(None),  # lpEntry : void*
    wintypes.DWORD,  # dwEntrySize : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminMIBEntryCreate = mprapi.NewProc("MprAdminMIBEntryCreate")
)

// hMibServer (INT_PTR), dwPid (DWORD), dwRoutingPid (DWORD), lpEntry (void*), dwEntrySize (DWORD)
r1, _, err := procMprAdminMIBEntryCreate.Call(
	uintptr(hMibServer),
	uintptr(dwPid),
	uintptr(dwRoutingPid),
	uintptr(lpEntry),
	uintptr(dwEntrySize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MprAdminMIBEntryCreate(
  hMibServer: NativeInt;   // INT_PTR
  dwPid: DWORD;   // DWORD
  dwRoutingPid: DWORD;   // DWORD
  lpEntry: Pointer;   // void*
  dwEntrySize: DWORD   // DWORD
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprAdminMIBEntryCreate';
result := DllCall("MPRAPI\MprAdminMIBEntryCreate"
    , "Ptr", hMibServer   ; INT_PTR
    , "UInt", dwPid   ; DWORD
    , "UInt", dwRoutingPid   ; DWORD
    , "Ptr", lpEntry   ; void*
    , "UInt", dwEntrySize   ; DWORD
    , "UInt")   ; return: DWORD
●MprAdminMIBEntryCreate(hMibServer, dwPid, dwRoutingPid, lpEntry, dwEntrySize) = DLL("MPRAPI.dll", "dword MprAdminMIBEntryCreate(int, dword, dword, void*, dword)")
# 呼び出し: MprAdminMIBEntryCreate(hMibServer, dwPid, dwRoutingPid, lpEntry, dwEntrySize)
# hMibServer : INT_PTR -> "int"
# dwPid : DWORD -> "dword"
# dwRoutingPid : DWORD -> "dword"
# lpEntry : void* -> "void*"
# dwEntrySize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

foreign import stdcall safe "MprAdminMIBEntryCreate"
  c_MprAdminMIBEntryCreate :: CIntPtr -> Word32 -> Word32 -> Ptr () -> Word32 -> IO Word32
-- hMibServer : INT_PTR -> CIntPtr
-- dwPid : DWORD -> Word32
-- dwRoutingPid : DWORD -> Word32
-- lpEntry : void* -> Ptr ()
-- dwEntrySize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mpradminmibentrycreate =
  foreign "MprAdminMIBEntryCreate"
    (intptr_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning uint32_t)
(* hMibServer : INT_PTR -> intptr_t *)
(* dwPid : DWORD -> uint32_t *)
(* dwRoutingPid : DWORD -> uint32_t *)
(* lpEntry : void* -> (ptr void) *)
(* dwEntrySize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprAdminMIBEntryCreate" mpr-admin-mibentry-create :convention :stdcall) :uint32
  (h-mib-server :int64)   ; INT_PTR
  (dw-pid :uint32)   ; DWORD
  (dw-routing-pid :uint32)   ; DWORD
  (lp-entry :pointer)   ; void*
  (dw-entry-size :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprAdminMIBEntryCreate = Win32::API::More->new('MPRAPI',
    'DWORD MprAdminMIBEntryCreate(LPARAM hMibServer, DWORD dwPid, DWORD dwRoutingPid, LPVOID lpEntry, DWORD dwEntrySize)');
# my $ret = $MprAdminMIBEntryCreate->Call($hMibServer, $dwPid, $dwRoutingPid, $lpEntry, $dwEntrySize);
# hMibServer : INT_PTR -> LPARAM
# dwPid : DWORD -> DWORD
# dwRoutingPid : DWORD -> DWORD
# lpEntry : void* -> LPVOID
# dwEntrySize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。