Win32 API 日本語リファレンス
ホームSystem.Rpc › MesBufferHandleReset

MesBufferHandleReset

関数
バッファシリアル化ハンドルを再利用のため再設定する。
DLLRPCRT4.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS MesBufferHandleReset(
    void* Handle,
    DWORD HandleStyle,
    MIDL_ES_CODE Operation,
    CHAR** pBuffer,   // optional
    DWORD BufferSize,
    DWORD* pEncodedSize   // optional
);

パラメーター

名前方向説明
Handlevoid*in再設定する既存のバッファ方式シリアライズハンドル。
HandleStyleDWORDinハンドルの方式を示す値。MES_FIXED_BUFFER_HANDLE等を指定する。
OperationMIDL_ES_CODEin操作種別を示すMIDL_ES_CODE列挙値。エンコードかデコードかを指定する。
pBufferCHAR**inoptionalバッファへのポインタ。固定長は入力、動的/復号は入出力として使う。
BufferSizeDWORDinバッファのバイトサイズ。
pEncodedSizeDWORD*outoptionalエンコードされたバイト数を受け取る出力ポインタ。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS MesBufferHandleReset(
    void* Handle,
    DWORD HandleStyle,
    MIDL_ES_CODE Operation,
    CHAR** pBuffer,   // optional
    DWORD BufferSize,
    DWORD* pEncodedSize   // optional
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int MesBufferHandleReset(
    IntPtr Handle,   // void*
    uint HandleStyle,   // DWORD
    int Operation,   // MIDL_ES_CODE
    IntPtr pBuffer,   // CHAR** optional
    uint BufferSize,   // DWORD
    IntPtr pEncodedSize   // DWORD* optional, out
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function MesBufferHandleReset(
    Handle As IntPtr,   ' void*
    HandleStyle As UInteger,   ' DWORD
    Operation As Integer,   ' MIDL_ES_CODE
    pBuffer As IntPtr,   ' CHAR** optional
    BufferSize As UInteger,   ' DWORD
    pEncodedSize As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' Handle : void*
' HandleStyle : DWORD
' Operation : MIDL_ES_CODE
' pBuffer : CHAR** optional
' BufferSize : DWORD
' pEncodedSize : DWORD* optional, out
Declare PtrSafe Function MesBufferHandleReset Lib "rpcrt4" ( _
    ByVal Handle As LongPtr, _
    ByVal HandleStyle As Long, _
    ByVal Operation As Long, _
    ByVal pBuffer As LongPtr, _
    ByVal BufferSize As Long, _
    ByVal pEncodedSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MesBufferHandleReset = ctypes.windll.rpcrt4.MesBufferHandleReset
MesBufferHandleReset.restype = ctypes.c_int
MesBufferHandleReset.argtypes = [
    ctypes.POINTER(None),  # Handle : void*
    wintypes.DWORD,  # HandleStyle : DWORD
    ctypes.c_int,  # Operation : MIDL_ES_CODE
    ctypes.c_void_p,  # pBuffer : CHAR** optional
    wintypes.DWORD,  # BufferSize : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pEncodedSize : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procMesBufferHandleReset = rpcrt4.NewProc("MesBufferHandleReset")
)

// Handle (void*), HandleStyle (DWORD), Operation (MIDL_ES_CODE), pBuffer (CHAR** optional), BufferSize (DWORD), pEncodedSize (DWORD* optional, out)
r1, _, err := procMesBufferHandleReset.Call(
	uintptr(Handle),
	uintptr(HandleStyle),
	uintptr(Operation),
	uintptr(pBuffer),
	uintptr(BufferSize),
	uintptr(pEncodedSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function MesBufferHandleReset(
  Handle: Pointer;   // void*
  HandleStyle: DWORD;   // DWORD
  Operation: Integer;   // MIDL_ES_CODE
  pBuffer: Pointer;   // CHAR** optional
  BufferSize: DWORD;   // DWORD
  pEncodedSize: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'MesBufferHandleReset';
result := DllCall("RPCRT4\MesBufferHandleReset"
    , "Ptr", Handle   ; void*
    , "UInt", HandleStyle   ; DWORD
    , "Int", Operation   ; MIDL_ES_CODE
    , "Ptr", pBuffer   ; CHAR** optional
    , "UInt", BufferSize   ; DWORD
    , "Ptr", pEncodedSize   ; DWORD* optional, out
    , "Int")   ; return: RPC_STATUS
●MesBufferHandleReset(Handle, HandleStyle, Operation, pBuffer, BufferSize, pEncodedSize) = DLL("RPCRT4.dll", "int MesBufferHandleReset(void*, dword, int, void*, dword, void*)")
# 呼び出し: MesBufferHandleReset(Handle, HandleStyle, Operation, pBuffer, BufferSize, pEncodedSize)
# Handle : void* -> "void*"
# HandleStyle : DWORD -> "dword"
# Operation : MIDL_ES_CODE -> "int"
# pBuffer : CHAR** optional -> "void*"
# BufferSize : DWORD -> "dword"
# pEncodedSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef MesBufferHandleResetNative = Int32 Function(Pointer<Void>, Uint32, Int32, Pointer<Int8>, Uint32, Pointer<Uint32>);
typedef MesBufferHandleResetDart = int Function(Pointer<Void>, int, int, Pointer<Int8>, int, Pointer<Uint32>);
final MesBufferHandleReset = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<MesBufferHandleResetNative, MesBufferHandleResetDart>('MesBufferHandleReset');
// Handle : void* -> Pointer<Void>
// HandleStyle : DWORD -> Uint32
// Operation : MIDL_ES_CODE -> Int32
// pBuffer : CHAR** optional -> Pointer<Int8>
// BufferSize : DWORD -> Uint32
// pEncodedSize : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MesBufferHandleReset(
  Handle: Pointer;   // void*
  HandleStyle: DWORD;   // DWORD
  Operation: Integer;   // MIDL_ES_CODE
  pBuffer: Pointer;   // CHAR** optional
  BufferSize: DWORD;   // DWORD
  pEncodedSize: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'MesBufferHandleReset';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MesBufferHandleReset"
  c_MesBufferHandleReset :: Ptr () -> Word32 -> Int32 -> Ptr Int8 -> Word32 -> Ptr Word32 -> IO Int32
-- Handle : void* -> Ptr ()
-- HandleStyle : DWORD -> Word32
-- Operation : MIDL_ES_CODE -> Int32
-- pBuffer : CHAR** optional -> Ptr Int8
-- BufferSize : DWORD -> Word32
-- pEncodedSize : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mesbufferhandlereset =
  foreign "MesBufferHandleReset"
    ((ptr void) @-> uint32_t @-> int32_t @-> (ptr int8_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* Handle : void* -> (ptr void) *)
(* HandleStyle : DWORD -> uint32_t *)
(* Operation : MIDL_ES_CODE -> int32_t *)
(* pBuffer : CHAR** optional -> (ptr int8_t) *)
(* BufferSize : DWORD -> uint32_t *)
(* pEncodedSize : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("MesBufferHandleReset" mes-buffer-handle-reset :convention :stdcall) :int32
  (handle :pointer)   ; void*
  (handle-style :uint32)   ; DWORD
  (operation :int32)   ; MIDL_ES_CODE
  (p-buffer :pointer)   ; CHAR** optional
  (buffer-size :uint32)   ; DWORD
  (p-encoded-size :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MesBufferHandleReset = Win32::API::More->new('RPCRT4',
    'int MesBufferHandleReset(LPVOID Handle, DWORD HandleStyle, int Operation, LPVOID pBuffer, DWORD BufferSize, LPVOID pEncodedSize)');
# my $ret = $MesBufferHandleReset->Call($Handle, $HandleStyle, $Operation, $pBuffer, $BufferSize, $pEncodedSize);
# Handle : void* -> LPVOID
# HandleStyle : DWORD -> DWORD
# Operation : MIDL_ES_CODE -> int
# pBuffer : CHAR** optional -> LPVOID
# BufferSize : DWORD -> DWORD
# pEncodedSize : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型