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)。