ホーム › System.Rpc › MesEncodeIncrementalHandleCreate
MesEncodeIncrementalHandleCreate
関数増分エンコード用のシリアル化ハンドルを作成する。
シグネチャ
// RPCRT4.dll
#include <windows.h>
RPC_STATUS MesEncodeIncrementalHandleCreate(
void* UserState,
MIDL_ES_ALLOC AllocFn,
MIDL_ES_WRITE WriteFn,
void** pHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| UserState | void* | inout | ユーザー定義の状態を保持するポインタ。コールバックに引き渡される。NULL可。 |
| AllocFn | MIDL_ES_ALLOC | in | エンコード時にバッファ確保を行うMIDL_ES_ALLOCコールバック。 |
| WriteFn | MIDL_ES_WRITE | in | エンコード済みデータを書き出すMIDL_ES_WRITEコールバック。 |
| pHandle | void** | inout | 生成されたシリアライズハンドルを受け取る出力ポインタ。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll
#include <windows.h>
RPC_STATUS MesEncodeIncrementalHandleCreate(
void* UserState,
MIDL_ES_ALLOC AllocFn,
MIDL_ES_WRITE WriteFn,
void** pHandle
);[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int MesEncodeIncrementalHandleCreate(
IntPtr UserState, // void* in/out
IntPtr AllocFn, // MIDL_ES_ALLOC
IntPtr WriteFn, // MIDL_ES_WRITE
IntPtr pHandle // void** in/out
);<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function MesEncodeIncrementalHandleCreate(
UserState As IntPtr, ' void* in/out
AllocFn As IntPtr, ' MIDL_ES_ALLOC
WriteFn As IntPtr, ' MIDL_ES_WRITE
pHandle As IntPtr ' void** in/out
) As Integer
End Function' UserState : void* in/out
' AllocFn : MIDL_ES_ALLOC
' WriteFn : MIDL_ES_WRITE
' pHandle : void** in/out
Declare PtrSafe Function MesEncodeIncrementalHandleCreate Lib "rpcrt4" ( _
ByVal UserState As LongPtr, _
ByVal AllocFn As LongPtr, _
ByVal WriteFn As LongPtr, _
ByVal pHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MesEncodeIncrementalHandleCreate = ctypes.windll.rpcrt4.MesEncodeIncrementalHandleCreate
MesEncodeIncrementalHandleCreate.restype = ctypes.c_int
MesEncodeIncrementalHandleCreate.argtypes = [
ctypes.POINTER(None), # UserState : void* in/out
ctypes.c_void_p, # AllocFn : MIDL_ES_ALLOC
ctypes.c_void_p, # WriteFn : MIDL_ES_WRITE
ctypes.c_void_p, # pHandle : void** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
MesEncodeIncrementalHandleCreate = Fiddle::Function.new(
lib['MesEncodeIncrementalHandleCreate'],
[
Fiddle::TYPE_VOIDP, # UserState : void* in/out
Fiddle::TYPE_VOIDP, # AllocFn : MIDL_ES_ALLOC
Fiddle::TYPE_VOIDP, # WriteFn : MIDL_ES_WRITE
Fiddle::TYPE_VOIDP, # pHandle : void** in/out
],
Fiddle::TYPE_INT)#[link(name = "rpcrt4")]
extern "system" {
fn MesEncodeIncrementalHandleCreate(
UserState: *mut (), // void* in/out
AllocFn: *const core::ffi::c_void, // MIDL_ES_ALLOC
WriteFn: *const core::ffi::c_void, // MIDL_ES_WRITE
pHandle: *mut *mut () // void** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll")]
public static extern int MesEncodeIncrementalHandleCreate(IntPtr UserState, IntPtr AllocFn, IntPtr WriteFn, IntPtr pHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_MesEncodeIncrementalHandleCreate' -Namespace Win32 -PassThru
# $api::MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)#uselib "RPCRT4.dll"
#func global MesEncodeIncrementalHandleCreate "MesEncodeIncrementalHandleCreate" sptr, sptr, sptr, sptr
; MesEncodeIncrementalHandleCreate UserState, AllocFn, WriteFn, pHandle ; 戻り値は stat
; UserState : void* in/out -> "sptr"
; AllocFn : MIDL_ES_ALLOC -> "sptr"
; WriteFn : MIDL_ES_WRITE -> "sptr"
; pHandle : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll"
#cfunc global MesEncodeIncrementalHandleCreate "MesEncodeIncrementalHandleCreate" sptr, sptr, sptr, sptr
; res = MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
; UserState : void* in/out -> "sptr"
; AllocFn : MIDL_ES_ALLOC -> "sptr"
; WriteFn : MIDL_ES_WRITE -> "sptr"
; pHandle : void** in/out -> "sptr"; RPC_STATUS MesEncodeIncrementalHandleCreate(void* UserState, MIDL_ES_ALLOC AllocFn, MIDL_ES_WRITE WriteFn, void** pHandle)
#uselib "RPCRT4.dll"
#cfunc global MesEncodeIncrementalHandleCreate "MesEncodeIncrementalHandleCreate" intptr, intptr, intptr, intptr
; res = MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
; UserState : void* in/out -> "intptr"
; AllocFn : MIDL_ES_ALLOC -> "intptr"
; WriteFn : MIDL_ES_WRITE -> "intptr"
; pHandle : void** in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procMesEncodeIncrementalHandleCreate = rpcrt4.NewProc("MesEncodeIncrementalHandleCreate")
)
// UserState (void* in/out), AllocFn (MIDL_ES_ALLOC), WriteFn (MIDL_ES_WRITE), pHandle (void** in/out)
r1, _, err := procMesEncodeIncrementalHandleCreate.Call(
uintptr(UserState),
uintptr(AllocFn),
uintptr(WriteFn),
uintptr(pHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction MesEncodeIncrementalHandleCreate(
UserState: Pointer; // void* in/out
AllocFn: Pointer; // MIDL_ES_ALLOC
WriteFn: Pointer; // MIDL_ES_WRITE
pHandle: Pointer // void** in/out
): Integer; stdcall;
external 'RPCRT4.dll' name 'MesEncodeIncrementalHandleCreate';result := DllCall("RPCRT4\MesEncodeIncrementalHandleCreate"
, "Ptr", UserState ; void* in/out
, "Ptr", AllocFn ; MIDL_ES_ALLOC
, "Ptr", WriteFn ; MIDL_ES_WRITE
, "Ptr", pHandle ; void** in/out
, "Int") ; return: RPC_STATUS●MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle) = DLL("RPCRT4.dll", "int MesEncodeIncrementalHandleCreate(void*, void*, void*, void*)")
# 呼び出し: MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
# UserState : void* in/out -> "void*"
# AllocFn : MIDL_ES_ALLOC -> "void*"
# WriteFn : MIDL_ES_WRITE -> "void*"
# pHandle : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcrt4" fn MesEncodeIncrementalHandleCreate(
UserState: ?*anyopaque, // void* in/out
AllocFn: ?*anyopaque, // MIDL_ES_ALLOC
WriteFn: ?*anyopaque, // MIDL_ES_WRITE
pHandle: ?*anyopaque // void** in/out
) callconv(std.os.windows.WINAPI) i32;proc MesEncodeIncrementalHandleCreate(
UserState: pointer, # void* in/out
AllocFn: pointer, # MIDL_ES_ALLOC
WriteFn: pointer, # MIDL_ES_WRITE
pHandle: pointer # void** in/out
): int32 {.importc: "MesEncodeIncrementalHandleCreate", stdcall, dynlib: "RPCRT4.dll".}pragma(lib, "rpcrt4");
extern(Windows)
int MesEncodeIncrementalHandleCreate(
void* UserState, // void* in/out
void* AllocFn, // MIDL_ES_ALLOC
void* WriteFn, // MIDL_ES_WRITE
void** pHandle // void** in/out
);ccall((:MesEncodeIncrementalHandleCreate, "RPCRT4.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
UserState, AllocFn, WriteFn, pHandle)
# UserState : void* in/out -> Ptr{Cvoid}
# AllocFn : MIDL_ES_ALLOC -> Ptr{Cvoid}
# WriteFn : MIDL_ES_WRITE -> Ptr{Cvoid}
# pHandle : void** in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MesEncodeIncrementalHandleCreate(
void* UserState,
void* AllocFn,
void* WriteFn,
void** pHandle);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
-- UserState : void* in/out
-- AllocFn : MIDL_ES_ALLOC
-- WriteFn : MIDL_ES_WRITE
-- pHandle : void** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const MesEncodeIncrementalHandleCreate = lib.func('__stdcall', 'MesEncodeIncrementalHandleCreate', 'int32_t', ['void *', 'void *', 'void *', 'void *']);
// MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
// UserState : void* in/out -> 'void *'
// AllocFn : MIDL_ES_ALLOC -> 'void *'
// WriteFn : MIDL_ES_WRITE -> 'void *'
// pHandle : void** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("RPCRT4.dll", {
MesEncodeIncrementalHandleCreate: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle)
// UserState : void* in/out -> "pointer"
// AllocFn : MIDL_ES_ALLOC -> "pointer"
// WriteFn : MIDL_ES_WRITE -> "pointer"
// pHandle : void** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MesEncodeIncrementalHandleCreate(
void* UserState,
void* AllocFn,
void* WriteFn,
void** pHandle);
C, "RPCRT4.dll");
// $ffi->MesEncodeIncrementalHandleCreate(UserState, AllocFn, WriteFn, pHandle);
// UserState : void* in/out
// AllocFn : MIDL_ES_ALLOC
// WriteFn : MIDL_ES_WRITE
// pHandle : void** in/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 MesEncodeIncrementalHandleCreate(
Pointer UserState, // void* in/out
Callback AllocFn, // MIDL_ES_ALLOC
Callback WriteFn, // MIDL_ES_WRITE
Pointer pHandle // void** in/out
);
}@[Link("rpcrt4")]
lib LibRPCRT4
fun MesEncodeIncrementalHandleCreate = MesEncodeIncrementalHandleCreate(
UserState : Void*, # void* in/out
AllocFn : Void*, # MIDL_ES_ALLOC
WriteFn : Void*, # MIDL_ES_WRITE
pHandle : Void** # void** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MesEncodeIncrementalHandleCreateNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef MesEncodeIncrementalHandleCreateDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final MesEncodeIncrementalHandleCreate = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<MesEncodeIncrementalHandleCreateNative, MesEncodeIncrementalHandleCreateDart>('MesEncodeIncrementalHandleCreate');
// UserState : void* in/out -> Pointer<Void>
// AllocFn : MIDL_ES_ALLOC -> Pointer<Void>
// WriteFn : MIDL_ES_WRITE -> Pointer<Void>
// pHandle : void** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MesEncodeIncrementalHandleCreate(
UserState: Pointer; // void* in/out
AllocFn: Pointer; // MIDL_ES_ALLOC
WriteFn: Pointer; // MIDL_ES_WRITE
pHandle: Pointer // void** in/out
): Integer; stdcall;
external 'RPCRT4.dll' name 'MesEncodeIncrementalHandleCreate';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MesEncodeIncrementalHandleCreate"
c_MesEncodeIncrementalHandleCreate :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- UserState : void* in/out -> Ptr ()
-- AllocFn : MIDL_ES_ALLOC -> Ptr ()
-- WriteFn : MIDL_ES_WRITE -> Ptr ()
-- pHandle : void** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mesencodeincrementalhandlecreate =
foreign "MesEncodeIncrementalHandleCreate"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* UserState : void* in/out -> (ptr void) *)
(* AllocFn : MIDL_ES_ALLOC -> (ptr void) *)
(* WriteFn : MIDL_ES_WRITE -> (ptr void) *)
(* pHandle : void** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)
(cffi:defcfun ("MesEncodeIncrementalHandleCreate" mes-encode-incremental-handle-create :convention :stdcall) :int32
(user-state :pointer) ; void* in/out
(alloc-fn :pointer) ; MIDL_ES_ALLOC
(write-fn :pointer) ; MIDL_ES_WRITE
(p-handle :pointer)) ; void** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MesEncodeIncrementalHandleCreate = Win32::API::More->new('RPCRT4',
'int MesEncodeIncrementalHandleCreate(LPVOID UserState, LPVOID AllocFn, LPVOID WriteFn, LPVOID pHandle)');
# my $ret = $MesEncodeIncrementalHandleCreate->Call($UserState, $AllocFn, $WriteFn, $pHandle);
# UserState : void* in/out -> LPVOID
# AllocFn : MIDL_ES_ALLOC -> LPVOID
# WriteFn : MIDL_ES_WRITE -> LPVOID
# pHandle : void** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。