Win32 API 日本語リファレンス
ホームStorage.Imapi › OpenIMsgOnIStg

OpenIMsgOnIStg

関数
IStorage上にIMessageオブジェクトを開く。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

INT OpenIMsgOnIStg(
    LPMSGSESS lpMsgSess,
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPALLOCATEMORE lpAllocateMore,
    LPFREEBUFFER lpFreeBuffer,
    IMalloc* lpMalloc,
    void* lpMapiSup,
    IStorage* lpStg,
    MSGCALLRELEASE* lpfMsgCallRelease,
    DWORD ulCallerData,
    DWORD ulFlags,
    IMessage** lppMsg
);

パラメーター

名前方向説明
lpMsgSessLPMSGSESSinメッセージが属するセッションのハンドル。NULL可。
lpAllocateBufferLPALLOCATEBUFFERinMAPIメモリ確保関数LPALLOCATEBUFFERへのポインタ。
lpAllocateMoreLPALLOCATEMOREin既存割当に追加確保するLPALLOCATEMORE関数へのポインタ。
lpFreeBufferLPFREEBUFFERinMAPIメモリ解放関数LPFREEBUFFERへのポインタ。
lpMallocIMalloc*inメモリ確保に用いるIMallocインターフェイスへのポインタ。
lpMapiSupvoid*inoutMAPIサポートオブジェクトへのポインタ。NULL可。
lpStgIStorage*inメッセージの基盤となるIStorageオブジェクトへのポインタ。
lpfMsgCallReleaseMSGCALLRELEASE*inout解放時に呼ばれるコールバック関数へのポインタ。NULL可。
ulCallerDataDWORDinコールバックへ渡す呼び出し側のデータ値。
ulFlagsDWORDinオープン動作を制御するフラグ。書き込み許可などを指定する。
lppMsgIMessage**out生成されたIMessageインターフェイスを受け取るポインタ。

戻り値の型: INT

各言語での呼び出し定義

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

INT OpenIMsgOnIStg(
    LPMSGSESS lpMsgSess,
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPALLOCATEMORE lpAllocateMore,
    LPFREEBUFFER lpFreeBuffer,
    IMalloc* lpMalloc,
    void* lpMapiSup,
    IStorage* lpStg,
    MSGCALLRELEASE* lpfMsgCallRelease,
    DWORD ulCallerData,
    DWORD ulFlags,
    IMessage** lppMsg
);
[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int OpenIMsgOnIStg(
    IntPtr lpMsgSess,   // LPMSGSESS
    IntPtr lpAllocateBuffer,   // LPALLOCATEBUFFER
    IntPtr lpAllocateMore,   // LPALLOCATEMORE
    IntPtr lpFreeBuffer,   // LPFREEBUFFER
    IntPtr lpMalloc,   // IMalloc*
    IntPtr lpMapiSup,   // void* in/out
    IntPtr lpStg,   // IStorage*
    IntPtr lpfMsgCallRelease,   // MSGCALLRELEASE* in/out
    uint ulCallerData,   // DWORD
    uint ulFlags,   // DWORD
    IntPtr lppMsg   // IMessage** out
);
<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function OpenIMsgOnIStg(
    lpMsgSess As IntPtr,   ' LPMSGSESS
    lpAllocateBuffer As IntPtr,   ' LPALLOCATEBUFFER
    lpAllocateMore As IntPtr,   ' LPALLOCATEMORE
    lpFreeBuffer As IntPtr,   ' LPFREEBUFFER
    lpMalloc As IntPtr,   ' IMalloc*
    lpMapiSup As IntPtr,   ' void* in/out
    lpStg As IntPtr,   ' IStorage*
    lpfMsgCallRelease As IntPtr,   ' MSGCALLRELEASE* in/out
    ulCallerData As UInteger,   ' DWORD
    ulFlags As UInteger,   ' DWORD
    lppMsg As IntPtr   ' IMessage** out
) As Integer
End Function
' lpMsgSess : LPMSGSESS
' lpAllocateBuffer : LPALLOCATEBUFFER
' lpAllocateMore : LPALLOCATEMORE
' lpFreeBuffer : LPFREEBUFFER
' lpMalloc : IMalloc*
' lpMapiSup : void* in/out
' lpStg : IStorage*
' lpfMsgCallRelease : MSGCALLRELEASE* in/out
' ulCallerData : DWORD
' ulFlags : DWORD
' lppMsg : IMessage** out
Declare PtrSafe Function OpenIMsgOnIStg Lib "mapi32" ( _
    ByVal lpMsgSess As LongPtr, _
    ByVal lpAllocateBuffer As LongPtr, _
    ByVal lpAllocateMore As LongPtr, _
    ByVal lpFreeBuffer As LongPtr, _
    ByVal lpMalloc As LongPtr, _
    ByVal lpMapiSup As LongPtr, _
    ByVal lpStg As LongPtr, _
    ByVal lpfMsgCallRelease As LongPtr, _
    ByVal ulCallerData As Long, _
    ByVal ulFlags As Long, _
    ByVal lppMsg As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OpenIMsgOnIStg = ctypes.windll.mapi32.OpenIMsgOnIStg
OpenIMsgOnIStg.restype = ctypes.c_int
OpenIMsgOnIStg.argtypes = [
    ctypes.c_ssize_t,  # lpMsgSess : LPMSGSESS
    ctypes.c_void_p,  # lpAllocateBuffer : LPALLOCATEBUFFER
    ctypes.c_void_p,  # lpAllocateMore : LPALLOCATEMORE
    ctypes.c_void_p,  # lpFreeBuffer : LPFREEBUFFER
    ctypes.c_void_p,  # lpMalloc : IMalloc*
    ctypes.POINTER(None),  # lpMapiSup : void* in/out
    ctypes.c_void_p,  # lpStg : IStorage*
    ctypes.c_void_p,  # lpfMsgCallRelease : MSGCALLRELEASE* in/out
    wintypes.DWORD,  # ulCallerData : DWORD
    wintypes.DWORD,  # ulFlags : DWORD
    ctypes.c_void_p,  # lppMsg : IMessage** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MAPI32.dll')
OpenIMsgOnIStg = Fiddle::Function.new(
  lib['OpenIMsgOnIStg'],
  [
    Fiddle::TYPE_INTPTR_T,  # lpMsgSess : LPMSGSESS
    Fiddle::TYPE_VOIDP,  # lpAllocateBuffer : LPALLOCATEBUFFER
    Fiddle::TYPE_VOIDP,  # lpAllocateMore : LPALLOCATEMORE
    Fiddle::TYPE_VOIDP,  # lpFreeBuffer : LPFREEBUFFER
    Fiddle::TYPE_VOIDP,  # lpMalloc : IMalloc*
    Fiddle::TYPE_VOIDP,  # lpMapiSup : void* in/out
    Fiddle::TYPE_VOIDP,  # lpStg : IStorage*
    Fiddle::TYPE_VOIDP,  # lpfMsgCallRelease : MSGCALLRELEASE* in/out
    -Fiddle::TYPE_INT,  # ulCallerData : DWORD
    -Fiddle::TYPE_INT,  # ulFlags : DWORD
    Fiddle::TYPE_VOIDP,  # lppMsg : IMessage** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mapi32")]
extern "system" {
    fn OpenIMsgOnIStg(
        lpMsgSess: isize,  // LPMSGSESS
        lpAllocateBuffer: *const core::ffi::c_void,  // LPALLOCATEBUFFER
        lpAllocateMore: *const core::ffi::c_void,  // LPALLOCATEMORE
        lpFreeBuffer: *const core::ffi::c_void,  // LPFREEBUFFER
        lpMalloc: *mut core::ffi::c_void,  // IMalloc*
        lpMapiSup: *mut (),  // void* in/out
        lpStg: *mut core::ffi::c_void,  // IStorage*
        lpfMsgCallRelease: *mut *const core::ffi::c_void,  // MSGCALLRELEASE* in/out
        ulCallerData: u32,  // DWORD
        ulFlags: u32,  // DWORD
        lppMsg: *mut *mut core::ffi::c_void  // IMessage** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MAPI32.dll")]
public static extern int OpenIMsgOnIStg(IntPtr lpMsgSess, IntPtr lpAllocateBuffer, IntPtr lpAllocateMore, IntPtr lpFreeBuffer, IntPtr lpMalloc, IntPtr lpMapiSup, IntPtr lpStg, IntPtr lpfMsgCallRelease, uint ulCallerData, uint ulFlags, IntPtr lppMsg);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MAPI32_OpenIMsgOnIStg' -Namespace Win32 -PassThru
# $api::OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
#uselib "MAPI32.dll"
#func global OpenIMsgOnIStg "OpenIMsgOnIStg" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; OpenIMsgOnIStg lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg   ; 戻り値は stat
; lpMsgSess : LPMSGSESS -> "sptr"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpAllocateMore : LPALLOCATEMORE -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpMalloc : IMalloc* -> "sptr"
; lpMapiSup : void* in/out -> "sptr"
; lpStg : IStorage* -> "sptr"
; lpfMsgCallRelease : MSGCALLRELEASE* in/out -> "sptr"
; ulCallerData : DWORD -> "sptr"
; ulFlags : DWORD -> "sptr"
; lppMsg : IMessage** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MAPI32.dll"
#cfunc global OpenIMsgOnIStg "OpenIMsgOnIStg" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, int, int, sptr
; res = OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
; lpMsgSess : LPMSGSESS -> "sptr"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpAllocateMore : LPALLOCATEMORE -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpMalloc : IMalloc* -> "sptr"
; lpMapiSup : void* in/out -> "sptr"
; lpStg : IStorage* -> "sptr"
; lpfMsgCallRelease : MSGCALLRELEASE* in/out -> "sptr"
; ulCallerData : DWORD -> "int"
; ulFlags : DWORD -> "int"
; lppMsg : IMessage** out -> "sptr"
; INT OpenIMsgOnIStg(LPMSGSESS lpMsgSess, LPALLOCATEBUFFER lpAllocateBuffer, LPALLOCATEMORE lpAllocateMore, LPFREEBUFFER lpFreeBuffer, IMalloc* lpMalloc, void* lpMapiSup, IStorage* lpStg, MSGCALLRELEASE* lpfMsgCallRelease, DWORD ulCallerData, DWORD ulFlags, IMessage** lppMsg)
#uselib "MAPI32.dll"
#cfunc global OpenIMsgOnIStg "OpenIMsgOnIStg" intptr, intptr, intptr, intptr, intptr, intptr, intptr, intptr, int, int, intptr
; res = OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
; lpMsgSess : LPMSGSESS -> "intptr"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "intptr"
; lpAllocateMore : LPALLOCATEMORE -> "intptr"
; lpFreeBuffer : LPFREEBUFFER -> "intptr"
; lpMalloc : IMalloc* -> "intptr"
; lpMapiSup : void* in/out -> "intptr"
; lpStg : IStorage* -> "intptr"
; lpfMsgCallRelease : MSGCALLRELEASE* in/out -> "intptr"
; ulCallerData : DWORD -> "int"
; ulFlags : DWORD -> "int"
; lppMsg : IMessage** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procOpenIMsgOnIStg = mapi32.NewProc("OpenIMsgOnIStg")
)

// lpMsgSess (LPMSGSESS), lpAllocateBuffer (LPALLOCATEBUFFER), lpAllocateMore (LPALLOCATEMORE), lpFreeBuffer (LPFREEBUFFER), lpMalloc (IMalloc*), lpMapiSup (void* in/out), lpStg (IStorage*), lpfMsgCallRelease (MSGCALLRELEASE* in/out), ulCallerData (DWORD), ulFlags (DWORD), lppMsg (IMessage** out)
r1, _, err := procOpenIMsgOnIStg.Call(
	uintptr(lpMsgSess),
	uintptr(lpAllocateBuffer),
	uintptr(lpAllocateMore),
	uintptr(lpFreeBuffer),
	uintptr(lpMalloc),
	uintptr(lpMapiSup),
	uintptr(lpStg),
	uintptr(lpfMsgCallRelease),
	uintptr(ulCallerData),
	uintptr(ulFlags),
	uintptr(lppMsg),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function OpenIMsgOnIStg(
  lpMsgSess: NativeInt;   // LPMSGSESS
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpAllocateMore: Pointer;   // LPALLOCATEMORE
  lpFreeBuffer: Pointer;   // LPFREEBUFFER
  lpMalloc: Pointer;   // IMalloc*
  lpMapiSup: Pointer;   // void* in/out
  lpStg: Pointer;   // IStorage*
  lpfMsgCallRelease: Pointer;   // MSGCALLRELEASE* in/out
  ulCallerData: DWORD;   // DWORD
  ulFlags: DWORD;   // DWORD
  lppMsg: Pointer   // IMessage** out
): Integer; stdcall;
  external 'MAPI32.dll' name 'OpenIMsgOnIStg';
result := DllCall("MAPI32\OpenIMsgOnIStg"
    , "Ptr", lpMsgSess   ; LPMSGSESS
    , "Ptr", lpAllocateBuffer   ; LPALLOCATEBUFFER
    , "Ptr", lpAllocateMore   ; LPALLOCATEMORE
    , "Ptr", lpFreeBuffer   ; LPFREEBUFFER
    , "Ptr", lpMalloc   ; IMalloc*
    , "Ptr", lpMapiSup   ; void* in/out
    , "Ptr", lpStg   ; IStorage*
    , "Ptr", lpfMsgCallRelease   ; MSGCALLRELEASE* in/out
    , "UInt", ulCallerData   ; DWORD
    , "UInt", ulFlags   ; DWORD
    , "Ptr", lppMsg   ; IMessage** out
    , "Int")   ; return: INT
●OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg) = DLL("MAPI32.dll", "int OpenIMsgOnIStg(int, void*, void*, void*, void*, void*, void*, void*, dword, dword, void*)")
# 呼び出し: OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
# lpMsgSess : LPMSGSESS -> "int"
# lpAllocateBuffer : LPALLOCATEBUFFER -> "void*"
# lpAllocateMore : LPALLOCATEMORE -> "void*"
# lpFreeBuffer : LPFREEBUFFER -> "void*"
# lpMalloc : IMalloc* -> "void*"
# lpMapiSup : void* in/out -> "void*"
# lpStg : IStorage* -> "void*"
# lpfMsgCallRelease : MSGCALLRELEASE* in/out -> "void*"
# ulCallerData : DWORD -> "dword"
# ulFlags : DWORD -> "dword"
# lppMsg : IMessage** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mapi32" fn OpenIMsgOnIStg(
    lpMsgSess: isize, // LPMSGSESS
    lpAllocateBuffer: ?*anyopaque, // LPALLOCATEBUFFER
    lpAllocateMore: ?*anyopaque, // LPALLOCATEMORE
    lpFreeBuffer: ?*anyopaque, // LPFREEBUFFER
    lpMalloc: ?*anyopaque, // IMalloc*
    lpMapiSup: ?*anyopaque, // void* in/out
    lpStg: ?*anyopaque, // IStorage*
    lpfMsgCallRelease: ?*anyopaque, // MSGCALLRELEASE* in/out
    ulCallerData: u32, // DWORD
    ulFlags: u32, // DWORD
    lppMsg: ?*anyopaque // IMessage** out
) callconv(std.os.windows.WINAPI) i32;
proc OpenIMsgOnIStg(
    lpMsgSess: int,  # LPMSGSESS
    lpAllocateBuffer: pointer,  # LPALLOCATEBUFFER
    lpAllocateMore: pointer,  # LPALLOCATEMORE
    lpFreeBuffer: pointer,  # LPFREEBUFFER
    lpMalloc: pointer,  # IMalloc*
    lpMapiSup: pointer,  # void* in/out
    lpStg: pointer,  # IStorage*
    lpfMsgCallRelease: pointer,  # MSGCALLRELEASE* in/out
    ulCallerData: uint32,  # DWORD
    ulFlags: uint32,  # DWORD
    lppMsg: pointer  # IMessage** out
): int32 {.importc: "OpenIMsgOnIStg", stdcall, dynlib: "MAPI32.dll".}
pragma(lib, "mapi32");
extern(Windows)
int OpenIMsgOnIStg(
    ptrdiff_t lpMsgSess,   // LPMSGSESS
    void* lpAllocateBuffer,   // LPALLOCATEBUFFER
    void* lpAllocateMore,   // LPALLOCATEMORE
    void* lpFreeBuffer,   // LPFREEBUFFER
    void* lpMalloc,   // IMalloc*
    void* lpMapiSup,   // void* in/out
    void* lpStg,   // IStorage*
    void* lpfMsgCallRelease,   // MSGCALLRELEASE* in/out
    uint ulCallerData,   // DWORD
    uint ulFlags,   // DWORD
    void* lppMsg   // IMessage** out
);
ccall((:OpenIMsgOnIStg, "MAPI32.dll"), stdcall, Int32,
      (Int, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, UInt32, UInt32, Ptr{Cvoid}),
      lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
# lpMsgSess : LPMSGSESS -> Int
# lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr{Cvoid}
# lpAllocateMore : LPALLOCATEMORE -> Ptr{Cvoid}
# lpFreeBuffer : LPFREEBUFFER -> Ptr{Cvoid}
# lpMalloc : IMalloc* -> Ptr{Cvoid}
# lpMapiSup : void* in/out -> Ptr{Cvoid}
# lpStg : IStorage* -> Ptr{Cvoid}
# lpfMsgCallRelease : MSGCALLRELEASE* in/out -> Ptr{Cvoid}
# ulCallerData : DWORD -> UInt32
# ulFlags : DWORD -> UInt32
# lppMsg : IMessage** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t OpenIMsgOnIStg(
    intptr_t lpMsgSess,
    void* lpAllocateBuffer,
    void* lpAllocateMore,
    void* lpFreeBuffer,
    void* lpMalloc,
    void* lpMapiSup,
    void* lpStg,
    void* lpfMsgCallRelease,
    uint32_t ulCallerData,
    uint32_t ulFlags,
    void* lppMsg);
]]
local mapi32 = ffi.load("mapi32")
-- mapi32.OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
-- lpMsgSess : LPMSGSESS
-- lpAllocateBuffer : LPALLOCATEBUFFER
-- lpAllocateMore : LPALLOCATEMORE
-- lpFreeBuffer : LPFREEBUFFER
-- lpMalloc : IMalloc*
-- lpMapiSup : void* in/out
-- lpStg : IStorage*
-- lpfMsgCallRelease : MSGCALLRELEASE* in/out
-- ulCallerData : DWORD
-- ulFlags : DWORD
-- lppMsg : IMessage** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MAPI32.dll');
const OpenIMsgOnIStg = lib.func('__stdcall', 'OpenIMsgOnIStg', 'int32_t', ['intptr_t', 'void *', 'void *', 'void *', 'void *', 'void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'void *']);
// OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
// lpMsgSess : LPMSGSESS -> 'intptr_t'
// lpAllocateBuffer : LPALLOCATEBUFFER -> 'void *'
// lpAllocateMore : LPALLOCATEMORE -> 'void *'
// lpFreeBuffer : LPFREEBUFFER -> 'void *'
// lpMalloc : IMalloc* -> 'void *'
// lpMapiSup : void* in/out -> 'void *'
// lpStg : IStorage* -> 'void *'
// lpfMsgCallRelease : MSGCALLRELEASE* in/out -> 'void *'
// ulCallerData : DWORD -> 'uint32_t'
// ulFlags : DWORD -> 'uint32_t'
// lppMsg : IMessage** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("MAPI32.dll", {
  OpenIMsgOnIStg: { parameters: ["isize", "pointer", "pointer", "pointer", "pointer", "pointer", "pointer", "pointer", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg)
// lpMsgSess : LPMSGSESS -> "isize"
// lpAllocateBuffer : LPALLOCATEBUFFER -> "pointer"
// lpAllocateMore : LPALLOCATEMORE -> "pointer"
// lpFreeBuffer : LPFREEBUFFER -> "pointer"
// lpMalloc : IMalloc* -> "pointer"
// lpMapiSup : void* in/out -> "pointer"
// lpStg : IStorage* -> "pointer"
// lpfMsgCallRelease : MSGCALLRELEASE* in/out -> "pointer"
// ulCallerData : DWORD -> "u32"
// ulFlags : DWORD -> "u32"
// lppMsg : IMessage** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t OpenIMsgOnIStg(
    intptr_t lpMsgSess,
    void* lpAllocateBuffer,
    void* lpAllocateMore,
    void* lpFreeBuffer,
    void* lpMalloc,
    void* lpMapiSup,
    void* lpStg,
    void* lpfMsgCallRelease,
    uint32_t ulCallerData,
    uint32_t ulFlags,
    void* lppMsg);
C, "MAPI32.dll");
// $ffi->OpenIMsgOnIStg(lpMsgSess, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, lpMapiSup, lpStg, lpfMsgCallRelease, ulCallerData, ulFlags, lppMsg);
// lpMsgSess : LPMSGSESS
// lpAllocateBuffer : LPALLOCATEBUFFER
// lpAllocateMore : LPALLOCATEMORE
// lpFreeBuffer : LPFREEBUFFER
// lpMalloc : IMalloc*
// lpMapiSup : void* in/out
// lpStg : IStorage*
// lpfMsgCallRelease : MSGCALLRELEASE* in/out
// ulCallerData : DWORD
// ulFlags : DWORD
// lppMsg : IMessage** 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 Mapi32 extends StdCallLibrary {
    Mapi32 INSTANCE = Native.load("mapi32", Mapi32.class);
    int OpenIMsgOnIStg(
        long lpMsgSess,   // LPMSGSESS
        Callback lpAllocateBuffer,   // LPALLOCATEBUFFER
        Callback lpAllocateMore,   // LPALLOCATEMORE
        Callback lpFreeBuffer,   // LPFREEBUFFER
        Pointer lpMalloc,   // IMalloc*
        Pointer lpMapiSup,   // void* in/out
        Pointer lpStg,   // IStorage*
        Callback lpfMsgCallRelease,   // MSGCALLRELEASE* in/out
        int ulCallerData,   // DWORD
        int ulFlags,   // DWORD
        Pointer lppMsg   // IMessage** out
    );
}
@[Link("mapi32")]
lib LibMAPI32
  fun OpenIMsgOnIStg = OpenIMsgOnIStg(
    lpMsgSess : LibC::SSizeT,   # LPMSGSESS
    lpAllocateBuffer : Void*,   # LPALLOCATEBUFFER
    lpAllocateMore : Void*,   # LPALLOCATEMORE
    lpFreeBuffer : Void*,   # LPFREEBUFFER
    lpMalloc : Void*,   # IMalloc*
    lpMapiSup : Void*,   # void* in/out
    lpStg : Void*,   # IStorage*
    lpfMsgCallRelease : Void*,   # MSGCALLRELEASE* in/out
    ulCallerData : UInt32,   # DWORD
    ulFlags : UInt32,   # DWORD
    lppMsg : Void*   # IMessage** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef OpenIMsgOnIStgNative = Int32 Function(IntPtr, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Pointer<Void>);
typedef OpenIMsgOnIStgDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, Pointer<Void>);
final OpenIMsgOnIStg = DynamicLibrary.open('MAPI32.dll')
    .lookupFunction<OpenIMsgOnIStgNative, OpenIMsgOnIStgDart>('OpenIMsgOnIStg');
// lpMsgSess : LPMSGSESS -> IntPtr
// lpAllocateBuffer : LPALLOCATEBUFFER -> Pointer<Void>
// lpAllocateMore : LPALLOCATEMORE -> Pointer<Void>
// lpFreeBuffer : LPFREEBUFFER -> Pointer<Void>
// lpMalloc : IMalloc* -> Pointer<Void>
// lpMapiSup : void* in/out -> Pointer<Void>
// lpStg : IStorage* -> Pointer<Void>
// lpfMsgCallRelease : MSGCALLRELEASE* in/out -> Pointer<Void>
// ulCallerData : DWORD -> Uint32
// ulFlags : DWORD -> Uint32
// lppMsg : IMessage** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function OpenIMsgOnIStg(
  lpMsgSess: NativeInt;   // LPMSGSESS
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpAllocateMore: Pointer;   // LPALLOCATEMORE
  lpFreeBuffer: Pointer;   // LPFREEBUFFER
  lpMalloc: Pointer;   // IMalloc*
  lpMapiSup: Pointer;   // void* in/out
  lpStg: Pointer;   // IStorage*
  lpfMsgCallRelease: Pointer;   // MSGCALLRELEASE* in/out
  ulCallerData: DWORD;   // DWORD
  ulFlags: DWORD;   // DWORD
  lppMsg: Pointer   // IMessage** out
): Integer; stdcall;
  external 'MAPI32.dll' name 'OpenIMsgOnIStg';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "OpenIMsgOnIStg"
  c_OpenIMsgOnIStg :: CIntPtr -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Ptr () -> IO Int32
-- lpMsgSess : LPMSGSESS -> CIntPtr
-- lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr ()
-- lpAllocateMore : LPALLOCATEMORE -> Ptr ()
-- lpFreeBuffer : LPFREEBUFFER -> Ptr ()
-- lpMalloc : IMalloc* -> Ptr ()
-- lpMapiSup : void* in/out -> Ptr ()
-- lpStg : IStorage* -> Ptr ()
-- lpfMsgCallRelease : MSGCALLRELEASE* in/out -> Ptr ()
-- ulCallerData : DWORD -> Word32
-- ulFlags : DWORD -> Word32
-- lppMsg : IMessage** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let openimsgonistg =
  foreign "OpenIMsgOnIStg"
    (intptr_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* lpMsgSess : LPMSGSESS -> intptr_t *)
(* lpAllocateBuffer : LPALLOCATEBUFFER -> (ptr void) *)
(* lpAllocateMore : LPALLOCATEMORE -> (ptr void) *)
(* lpFreeBuffer : LPFREEBUFFER -> (ptr void) *)
(* lpMalloc : IMalloc* -> (ptr void) *)
(* lpMapiSup : void* in/out -> (ptr void) *)
(* lpStg : IStorage* -> (ptr void) *)
(* lpfMsgCallRelease : MSGCALLRELEASE* in/out -> (ptr void) *)
(* ulCallerData : DWORD -> uint32_t *)
(* ulFlags : DWORD -> uint32_t *)
(* lppMsg : IMessage** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mapi32 (t "MAPI32.dll"))
(cffi:use-foreign-library mapi32)

(cffi:defcfun ("OpenIMsgOnIStg" open-imsg-on-istg :convention :stdcall) :int32
  (lp-msg-sess :int64)   ; LPMSGSESS
  (lp-allocate-buffer :pointer)   ; LPALLOCATEBUFFER
  (lp-allocate-more :pointer)   ; LPALLOCATEMORE
  (lp-free-buffer :pointer)   ; LPFREEBUFFER
  (lp-malloc :pointer)   ; IMalloc*
  (lp-mapi-sup :pointer)   ; void* in/out
  (lp-stg :pointer)   ; IStorage*
  (lpf-msg-call-release :pointer)   ; MSGCALLRELEASE* in/out
  (ul-caller-data :uint32)   ; DWORD
  (ul-flags :uint32)   ; DWORD
  (lpp-msg :pointer))   ; IMessage** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $OpenIMsgOnIStg = Win32::API::More->new('MAPI32',
    'int OpenIMsgOnIStg(LPARAM lpMsgSess, LPVOID lpAllocateBuffer, LPVOID lpAllocateMore, LPVOID lpFreeBuffer, LPVOID lpMalloc, LPVOID lpMapiSup, LPVOID lpStg, LPVOID lpfMsgCallRelease, DWORD ulCallerData, DWORD ulFlags, LPVOID lppMsg)');
# my $ret = $OpenIMsgOnIStg->Call($lpMsgSess, $lpAllocateBuffer, $lpAllocateMore, $lpFreeBuffer, $lpMalloc, $lpMapiSup, $lpStg, $lpfMsgCallRelease, $ulCallerData, $ulFlags, $lppMsg);
# lpMsgSess : LPMSGSESS -> LPARAM
# lpAllocateBuffer : LPALLOCATEBUFFER -> LPVOID
# lpAllocateMore : LPALLOCATEMORE -> LPVOID
# lpFreeBuffer : LPFREEBUFFER -> LPVOID
# lpMalloc : IMalloc* -> LPVOID
# lpMapiSup : void* in/out -> LPVOID
# lpStg : IStorage* -> LPVOID
# lpfMsgCallRelease : MSGCALLRELEASE* in/out -> LPVOID
# ulCallerData : DWORD -> DWORD
# ulFlags : DWORD -> DWORD
# lppMsg : IMessage** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型