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

BuildDisplayTable

関数
プロパティページ用の表示テーブルを構築する。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

HRESULT BuildDisplayTable(
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPALLOCATEMORE lpAllocateMore,
    LPFREEBUFFER lpFreeBuffer,
    IMalloc* lpMalloc,
    HINSTANCE hInstance,
    DWORD cPages,
    DTPAGE* lpPage,
    DWORD ulFlags,
    IMAPITable** lppTable,
    ITableData** lppTblData
);

パラメーター

名前方向説明
lpAllocateBufferLPALLOCATEBUFFERinメモリ確保に用いるAllocateBuffer関数へのポインタ。
lpAllocateMoreLPALLOCATEMOREin既存割り当てに追加メモリを確保するAllocateMore関数へのポインタ。
lpFreeBufferLPFREEBUFFERin確保したメモリを解放するFreeBuffer関数へのポインタ。
lpMallocIMalloc*inCOMメモリ確保に用いるIMallocインターフェイスへのポインタ。
hInstanceHINSTANCEinダイアログリソースを含むモジュールのインスタンスハンドル。
cPagesDWORDin表示テーブルのページ数を示すDWORD値。lpPage配列の要素数を表す。
lpPageDTPAGE*inout各ページの定義を格納したDTPAGE配列へのポインタ。
ulFlagsDWORDinテーブル構築動作を制御するDWORDフラグ。文字セット指定などに用いる。
lppTableIMAPITable**out構築された表示用IMAPITableインターフェイスを受け取る出力ポインタ。
lppTblDataITableData**out基となるITableDataインターフェイスを受け取る出力ポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT BuildDisplayTable(
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPALLOCATEMORE lpAllocateMore,
    LPFREEBUFFER lpFreeBuffer,
    IMalloc* lpMalloc,
    HINSTANCE hInstance,
    DWORD cPages,
    DTPAGE* lpPage,
    DWORD ulFlags,
    IMAPITable** lppTable,
    ITableData** lppTblData
);
[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int BuildDisplayTable(
    IntPtr lpAllocateBuffer,   // LPALLOCATEBUFFER
    IntPtr lpAllocateMore,   // LPALLOCATEMORE
    IntPtr lpFreeBuffer,   // LPFREEBUFFER
    IntPtr lpMalloc,   // IMalloc*
    IntPtr hInstance,   // HINSTANCE
    uint cPages,   // DWORD
    IntPtr lpPage,   // DTPAGE* in/out
    uint ulFlags,   // DWORD
    IntPtr lppTable,   // IMAPITable** out
    IntPtr lppTblData   // ITableData** out
);
<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function BuildDisplayTable(
    lpAllocateBuffer As IntPtr,   ' LPALLOCATEBUFFER
    lpAllocateMore As IntPtr,   ' LPALLOCATEMORE
    lpFreeBuffer As IntPtr,   ' LPFREEBUFFER
    lpMalloc As IntPtr,   ' IMalloc*
    hInstance As IntPtr,   ' HINSTANCE
    cPages As UInteger,   ' DWORD
    lpPage As IntPtr,   ' DTPAGE* in/out
    ulFlags As UInteger,   ' DWORD
    lppTable As IntPtr,   ' IMAPITable** out
    lppTblData As IntPtr   ' ITableData** out
) As Integer
End Function
' lpAllocateBuffer : LPALLOCATEBUFFER
' lpAllocateMore : LPALLOCATEMORE
' lpFreeBuffer : LPFREEBUFFER
' lpMalloc : IMalloc*
' hInstance : HINSTANCE
' cPages : DWORD
' lpPage : DTPAGE* in/out
' ulFlags : DWORD
' lppTable : IMAPITable** out
' lppTblData : ITableData** out
Declare PtrSafe Function BuildDisplayTable Lib "mapi32" ( _
    ByVal lpAllocateBuffer As LongPtr, _
    ByVal lpAllocateMore As LongPtr, _
    ByVal lpFreeBuffer As LongPtr, _
    ByVal lpMalloc As LongPtr, _
    ByVal hInstance As LongPtr, _
    ByVal cPages As Long, _
    ByVal lpPage As LongPtr, _
    ByVal ulFlags As Long, _
    ByVal lppTable As LongPtr, _
    ByVal lppTblData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BuildDisplayTable = ctypes.windll.mapi32.BuildDisplayTable
BuildDisplayTable.restype = ctypes.c_int
BuildDisplayTable.argtypes = [
    ctypes.c_void_p,  # lpAllocateBuffer : LPALLOCATEBUFFER
    ctypes.c_void_p,  # lpAllocateMore : LPALLOCATEMORE
    ctypes.c_void_p,  # lpFreeBuffer : LPFREEBUFFER
    ctypes.c_void_p,  # lpMalloc : IMalloc*
    wintypes.HANDLE,  # hInstance : HINSTANCE
    wintypes.DWORD,  # cPages : DWORD
    ctypes.c_void_p,  # lpPage : DTPAGE* in/out
    wintypes.DWORD,  # ulFlags : DWORD
    ctypes.c_void_p,  # lppTable : IMAPITable** out
    ctypes.c_void_p,  # lppTblData : ITableData** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MAPI32.dll')
BuildDisplayTable = Fiddle::Function.new(
  lib['BuildDisplayTable'],
  [
    Fiddle::TYPE_VOIDP,  # lpAllocateBuffer : LPALLOCATEBUFFER
    Fiddle::TYPE_VOIDP,  # lpAllocateMore : LPALLOCATEMORE
    Fiddle::TYPE_VOIDP,  # lpFreeBuffer : LPFREEBUFFER
    Fiddle::TYPE_VOIDP,  # lpMalloc : IMalloc*
    Fiddle::TYPE_VOIDP,  # hInstance : HINSTANCE
    -Fiddle::TYPE_INT,  # cPages : DWORD
    Fiddle::TYPE_VOIDP,  # lpPage : DTPAGE* in/out
    -Fiddle::TYPE_INT,  # ulFlags : DWORD
    Fiddle::TYPE_VOIDP,  # lppTable : IMAPITable** out
    Fiddle::TYPE_VOIDP,  # lppTblData : ITableData** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mapi32")]
extern "system" {
    fn BuildDisplayTable(
        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*
        hInstance: *mut core::ffi::c_void,  // HINSTANCE
        cPages: u32,  // DWORD
        lpPage: *mut DTPAGE,  // DTPAGE* in/out
        ulFlags: u32,  // DWORD
        lppTable: *mut *mut core::ffi::c_void,  // IMAPITable** out
        lppTblData: *mut *mut core::ffi::c_void  // ITableData** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MAPI32.dll")]
public static extern int BuildDisplayTable(IntPtr lpAllocateBuffer, IntPtr lpAllocateMore, IntPtr lpFreeBuffer, IntPtr lpMalloc, IntPtr hInstance, uint cPages, IntPtr lpPage, uint ulFlags, IntPtr lppTable, IntPtr lppTblData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MAPI32_BuildDisplayTable' -Namespace Win32 -PassThru
# $api::BuildDisplayTable(lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, lpPage, ulFlags, lppTable, lppTblData)
#uselib "MAPI32.dll"
#func global BuildDisplayTable "BuildDisplayTable" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; BuildDisplayTable lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, varptr(lpPage), ulFlags, lppTable, lppTblData   ; 戻り値は stat
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpAllocateMore : LPALLOCATEMORE -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpMalloc : IMalloc* -> "sptr"
; hInstance : HINSTANCE -> "sptr"
; cPages : DWORD -> "sptr"
; lpPage : DTPAGE* in/out -> "sptr"
; ulFlags : DWORD -> "sptr"
; lppTable : IMAPITable** out -> "sptr"
; lppTblData : ITableData** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MAPI32.dll"
#cfunc global BuildDisplayTable "BuildDisplayTable" sptr, sptr, sptr, sptr, sptr, int, var, int, sptr, sptr
; res = BuildDisplayTable(lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, lpPage, ulFlags, lppTable, lppTblData)
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpAllocateMore : LPALLOCATEMORE -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpMalloc : IMalloc* -> "sptr"
; hInstance : HINSTANCE -> "sptr"
; cPages : DWORD -> "int"
; lpPage : DTPAGE* in/out -> "var"
; ulFlags : DWORD -> "int"
; lppTable : IMAPITable** out -> "sptr"
; lppTblData : ITableData** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT BuildDisplayTable(LPALLOCATEBUFFER lpAllocateBuffer, LPALLOCATEMORE lpAllocateMore, LPFREEBUFFER lpFreeBuffer, IMalloc* lpMalloc, HINSTANCE hInstance, DWORD cPages, DTPAGE* lpPage, DWORD ulFlags, IMAPITable** lppTable, ITableData** lppTblData)
#uselib "MAPI32.dll"
#cfunc global BuildDisplayTable "BuildDisplayTable" intptr, intptr, intptr, intptr, intptr, int, var, int, intptr, intptr
; res = BuildDisplayTable(lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, lpPage, ulFlags, lppTable, lppTblData)
; lpAllocateBuffer : LPALLOCATEBUFFER -> "intptr"
; lpAllocateMore : LPALLOCATEMORE -> "intptr"
; lpFreeBuffer : LPFREEBUFFER -> "intptr"
; lpMalloc : IMalloc* -> "intptr"
; hInstance : HINSTANCE -> "intptr"
; cPages : DWORD -> "int"
; lpPage : DTPAGE* in/out -> "var"
; ulFlags : DWORD -> "int"
; lppTable : IMAPITable** out -> "intptr"
; lppTblData : ITableData** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procBuildDisplayTable = mapi32.NewProc("BuildDisplayTable")
)

// lpAllocateBuffer (LPALLOCATEBUFFER), lpAllocateMore (LPALLOCATEMORE), lpFreeBuffer (LPFREEBUFFER), lpMalloc (IMalloc*), hInstance (HINSTANCE), cPages (DWORD), lpPage (DTPAGE* in/out), ulFlags (DWORD), lppTable (IMAPITable** out), lppTblData (ITableData** out)
r1, _, err := procBuildDisplayTable.Call(
	uintptr(lpAllocateBuffer),
	uintptr(lpAllocateMore),
	uintptr(lpFreeBuffer),
	uintptr(lpMalloc),
	uintptr(hInstance),
	uintptr(cPages),
	uintptr(lpPage),
	uintptr(ulFlags),
	uintptr(lppTable),
	uintptr(lppTblData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function BuildDisplayTable(
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpAllocateMore: Pointer;   // LPALLOCATEMORE
  lpFreeBuffer: Pointer;   // LPFREEBUFFER
  lpMalloc: Pointer;   // IMalloc*
  hInstance: THandle;   // HINSTANCE
  cPages: DWORD;   // DWORD
  lpPage: Pointer;   // DTPAGE* in/out
  ulFlags: DWORD;   // DWORD
  lppTable: Pointer;   // IMAPITable** out
  lppTblData: Pointer   // ITableData** out
): Integer; stdcall;
  external 'MAPI32.dll' name 'BuildDisplayTable';
result := DllCall("MAPI32\BuildDisplayTable"
    , "Ptr", lpAllocateBuffer   ; LPALLOCATEBUFFER
    , "Ptr", lpAllocateMore   ; LPALLOCATEMORE
    , "Ptr", lpFreeBuffer   ; LPFREEBUFFER
    , "Ptr", lpMalloc   ; IMalloc*
    , "Ptr", hInstance   ; HINSTANCE
    , "UInt", cPages   ; DWORD
    , "Ptr", lpPage   ; DTPAGE* in/out
    , "UInt", ulFlags   ; DWORD
    , "Ptr", lppTable   ; IMAPITable** out
    , "Ptr", lppTblData   ; ITableData** out
    , "Int")   ; return: HRESULT
●BuildDisplayTable(lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, lpPage, ulFlags, lppTable, lppTblData) = DLL("MAPI32.dll", "int BuildDisplayTable(void*, void*, void*, void*, void*, dword, void*, dword, void*, void*)")
# 呼び出し: BuildDisplayTable(lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpMalloc, hInstance, cPages, lpPage, ulFlags, lppTable, lppTblData)
# lpAllocateBuffer : LPALLOCATEBUFFER -> "void*"
# lpAllocateMore : LPALLOCATEMORE -> "void*"
# lpFreeBuffer : LPFREEBUFFER -> "void*"
# lpMalloc : IMalloc* -> "void*"
# hInstance : HINSTANCE -> "void*"
# cPages : DWORD -> "dword"
# lpPage : DTPAGE* in/out -> "void*"
# ulFlags : DWORD -> "dword"
# lppTable : IMAPITable** out -> "void*"
# lppTblData : ITableData** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef BuildDisplayTableNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Void>, Pointer<Void>);
typedef BuildDisplayTableDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>, Pointer<Void>);
final BuildDisplayTable = DynamicLibrary.open('MAPI32.dll')
    .lookupFunction<BuildDisplayTableNative, BuildDisplayTableDart>('BuildDisplayTable');
// lpAllocateBuffer : LPALLOCATEBUFFER -> Pointer<Void>
// lpAllocateMore : LPALLOCATEMORE -> Pointer<Void>
// lpFreeBuffer : LPFREEBUFFER -> Pointer<Void>
// lpMalloc : IMalloc* -> Pointer<Void>
// hInstance : HINSTANCE -> Pointer<Void>
// cPages : DWORD -> Uint32
// lpPage : DTPAGE* in/out -> Pointer<Void>
// ulFlags : DWORD -> Uint32
// lppTable : IMAPITable** out -> Pointer<Void>
// lppTblData : ITableData** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BuildDisplayTable(
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpAllocateMore: Pointer;   // LPALLOCATEMORE
  lpFreeBuffer: Pointer;   // LPFREEBUFFER
  lpMalloc: Pointer;   // IMalloc*
  hInstance: THandle;   // HINSTANCE
  cPages: DWORD;   // DWORD
  lpPage: Pointer;   // DTPAGE* in/out
  ulFlags: DWORD;   // DWORD
  lppTable: Pointer;   // IMAPITable** out
  lppTblData: Pointer   // ITableData** out
): Integer; stdcall;
  external 'MAPI32.dll' name 'BuildDisplayTable';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BuildDisplayTable"
  c_BuildDisplayTable :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr ()
-- lpAllocateMore : LPALLOCATEMORE -> Ptr ()
-- lpFreeBuffer : LPFREEBUFFER -> Ptr ()
-- lpMalloc : IMalloc* -> Ptr ()
-- hInstance : HINSTANCE -> Ptr ()
-- cPages : DWORD -> Word32
-- lpPage : DTPAGE* in/out -> Ptr ()
-- ulFlags : DWORD -> Word32
-- lppTable : IMAPITable** out -> Ptr ()
-- lppTblData : ITableData** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let builddisplaytable =
  foreign "BuildDisplayTable"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* lpAllocateBuffer : LPALLOCATEBUFFER -> (ptr void) *)
(* lpAllocateMore : LPALLOCATEMORE -> (ptr void) *)
(* lpFreeBuffer : LPFREEBUFFER -> (ptr void) *)
(* lpMalloc : IMalloc* -> (ptr void) *)
(* hInstance : HINSTANCE -> (ptr void) *)
(* cPages : DWORD -> uint32_t *)
(* lpPage : DTPAGE* in/out -> (ptr void) *)
(* ulFlags : DWORD -> uint32_t *)
(* lppTable : IMAPITable** out -> (ptr void) *)
(* lppTblData : ITableData** 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 ("BuildDisplayTable" build-display-table :convention :stdcall) :int32
  (lp-allocate-buffer :pointer)   ; LPALLOCATEBUFFER
  (lp-allocate-more :pointer)   ; LPALLOCATEMORE
  (lp-free-buffer :pointer)   ; LPFREEBUFFER
  (lp-malloc :pointer)   ; IMalloc*
  (h-instance :pointer)   ; HINSTANCE
  (c-pages :uint32)   ; DWORD
  (lp-page :pointer)   ; DTPAGE* in/out
  (ul-flags :uint32)   ; DWORD
  (lpp-table :pointer)   ; IMAPITable** out
  (lpp-tbl-data :pointer))   ; ITableData** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BuildDisplayTable = Win32::API::More->new('MAPI32',
    'int BuildDisplayTable(LPVOID lpAllocateBuffer, LPVOID lpAllocateMore, LPVOID lpFreeBuffer, LPVOID lpMalloc, HANDLE hInstance, DWORD cPages, LPVOID lpPage, DWORD ulFlags, LPVOID lppTable, LPVOID lppTblData)');
# my $ret = $BuildDisplayTable->Call($lpAllocateBuffer, $lpAllocateMore, $lpFreeBuffer, $lpMalloc, $hInstance, $cPages, $lpPage, $ulFlags, $lppTable, $lppTblData);
# lpAllocateBuffer : LPALLOCATEBUFFER -> LPVOID
# lpAllocateMore : LPALLOCATEMORE -> LPVOID
# lpFreeBuffer : LPFREEBUFFER -> LPVOID
# lpMalloc : IMalloc* -> LPVOID
# hInstance : HINSTANCE -> HANDLE
# cPages : DWORD -> DWORD
# lpPage : DTPAGE* in/out -> LPVOID
# ulFlags : DWORD -> DWORD
# lppTable : IMAPITable** out -> LPVOID
# lppTblData : ITableData** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型