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

MprInfoBlockAdd

関数
情報ヘッダーに新しい情報ブロックを追加する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprInfoBlockAdd(
    void* lpHeader,
    DWORD dwInfoType,
    DWORD dwItemSize,
    DWORD dwItemCount,
    BYTE* lpItemData,
    void** lplpNewHeader
);

パラメーター

名前方向説明
lpHeadervoid*inブロックを追加する元の情報ヘッダーへのポインタ。
dwInfoTypeDWORDin追加する情報ブロックの種類を示す型識別子。
dwItemSizeDWORDinブロック内の各項目のサイズ(バイト単位)。
dwItemCountDWORDinブロックに含まれる項目数。
lpItemDataBYTE*in追加する項目データを格納したバッファへのポインタ。
lplpNewHeadervoid**outブロック追加後の新しいヘッダーへのポインタを受け取る。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprInfoBlockAdd(
    void* lpHeader,
    DWORD dwInfoType,
    DWORD dwItemSize,
    DWORD dwItemCount,
    BYTE* lpItemData,
    void** lplpNewHeader
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprInfoBlockAdd(
    IntPtr lpHeader,   // void*
    uint dwInfoType,   // DWORD
    uint dwItemSize,   // DWORD
    uint dwItemCount,   // DWORD
    IntPtr lpItemData,   // BYTE*
    IntPtr lplpNewHeader   // void** out
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprInfoBlockAdd(
    lpHeader As IntPtr,   ' void*
    dwInfoType As UInteger,   ' DWORD
    dwItemSize As UInteger,   ' DWORD
    dwItemCount As UInteger,   ' DWORD
    lpItemData As IntPtr,   ' BYTE*
    lplpNewHeader As IntPtr   ' void** out
) As UInteger
End Function
' lpHeader : void*
' dwInfoType : DWORD
' dwItemSize : DWORD
' dwItemCount : DWORD
' lpItemData : BYTE*
' lplpNewHeader : void** out
Declare PtrSafe Function MprInfoBlockAdd Lib "mprapi" ( _
    ByVal lpHeader As LongPtr, _
    ByVal dwInfoType As Long, _
    ByVal dwItemSize As Long, _
    ByVal dwItemCount As Long, _
    ByVal lpItemData As LongPtr, _
    ByVal lplpNewHeader As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprInfoBlockAdd = ctypes.windll.mprapi.MprInfoBlockAdd
MprInfoBlockAdd.restype = wintypes.DWORD
MprInfoBlockAdd.argtypes = [
    ctypes.POINTER(None),  # lpHeader : void*
    wintypes.DWORD,  # dwInfoType : DWORD
    wintypes.DWORD,  # dwItemSize : DWORD
    wintypes.DWORD,  # dwItemCount : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # lpItemData : BYTE*
    ctypes.c_void_p,  # lplpNewHeader : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprInfoBlockAdd = mprapi.NewProc("MprInfoBlockAdd")
)

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

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

typedef MprInfoBlockAddNative = Uint32 Function(Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Uint8>, Pointer<Void>);
typedef MprInfoBlockAddDart = int Function(Pointer<Void>, int, int, int, Pointer<Uint8>, Pointer<Void>);
final MprInfoBlockAdd = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprInfoBlockAddNative, MprInfoBlockAddDart>('MprInfoBlockAdd');
// lpHeader : void* -> Pointer<Void>
// dwInfoType : DWORD -> Uint32
// dwItemSize : DWORD -> Uint32
// dwItemCount : DWORD -> Uint32
// lpItemData : BYTE* -> Pointer<Uint8>
// lplpNewHeader : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprInfoBlockAdd(
  lpHeader: Pointer;   // void*
  dwInfoType: DWORD;   // DWORD
  dwItemSize: DWORD;   // DWORD
  dwItemCount: DWORD;   // DWORD
  lpItemData: Pointer;   // BYTE*
  lplpNewHeader: Pointer   // void** out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprInfoBlockAdd';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprInfoBlockAdd"
  c_MprInfoBlockAdd :: Ptr () -> Word32 -> Word32 -> Word32 -> Ptr Word8 -> Ptr () -> IO Word32
-- lpHeader : void* -> Ptr ()
-- dwInfoType : DWORD -> Word32
-- dwItemSize : DWORD -> Word32
-- dwItemCount : DWORD -> Word32
-- lpItemData : BYTE* -> Ptr Word8
-- lplpNewHeader : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mprinfoblockadd =
  foreign "MprInfoBlockAdd"
    ((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint8_t) @-> (ptr void) @-> returning uint32_t)
(* lpHeader : void* -> (ptr void) *)
(* dwInfoType : DWORD -> uint32_t *)
(* dwItemSize : DWORD -> uint32_t *)
(* dwItemCount : DWORD -> uint32_t *)
(* lpItemData : BYTE* -> (ptr uint8_t) *)
(* lplpNewHeader : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprInfoBlockAdd" mpr-info-block-add :convention :stdcall) :uint32
  (lp-header :pointer)   ; void*
  (dw-info-type :uint32)   ; DWORD
  (dw-item-size :uint32)   ; DWORD
  (dw-item-count :uint32)   ; DWORD
  (lp-item-data :pointer)   ; BYTE*
  (lplp-new-header :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprInfoBlockAdd = Win32::API::More->new('MPRAPI',
    'DWORD MprInfoBlockAdd(LPVOID lpHeader, DWORD dwInfoType, DWORD dwItemSize, DWORD dwItemCount, LPVOID lpItemData, LPVOID lplpNewHeader)');
# my $ret = $MprInfoBlockAdd->Call($lpHeader, $dwInfoType, $dwItemSize, $dwItemCount, $lpItemData, $lplpNewHeader);
# lpHeader : void* -> LPVOID
# dwInfoType : DWORD -> DWORD
# dwItemSize : DWORD -> DWORD
# dwItemCount : DWORD -> DWORD
# lpItemData : BYTE* -> LPVOID
# lplpNewHeader : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。