ホーム › System.AddressBook › CreateTable
CreateTable
関数MAPIのインメモリテーブルデータオブジェクトを作成する。
シグネチャ
// rtm.dll
#include <windows.h>
INT CreateTable(
GUID* lpInterface,
LPALLOCATEBUFFER lpAllocateBuffer,
LPALLOCATEMORE lpAllocateMore,
LPFREEBUFFER lpFreeBuffer,
void* lpvReserved,
DWORD ulTableType,
DWORD ulPropTagIndexColumn,
SPropTagArray* lpSPropTagArrayColumns,
ITableData** lppTableData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpInterface | GUID* | inout | 作成するテーブルのインターフェイス識別子GUIDへのポインタ。通常はNULLで既定を使う。 |
| lpAllocateBuffer | LPALLOCATEBUFFER | in | メモリ確保に用いるMAPIのAllocateBuffer関数へのポインタ。 |
| lpAllocateMore | LPALLOCATEMORE | in | 既存割り当てに追加メモリを確保するAllocateMore関数へのポインタ。 |
| lpFreeBuffer | LPFREEBUFFER | in | 確保したメモリを解放するFreeBuffer関数へのポインタ。 |
| lpvReserved | void* | inout | 予約パラメータ。NULLを指定する。 |
| ulTableType | DWORD | in | 作成するテーブルの種類を示すDWORD値。 |
| ulPropTagIndexColumn | DWORD | in | 行のインデックスとして使う列のプロパティタグを示すDWORD値。 |
| lpSPropTagArrayColumns | SPropTagArray* | inout | テーブルの列を定義するSPropTagArrayへのポインタ。各プロパティタグが列を表す。 |
| lppTableData | ITableData** | out | 作成されたITableDataインターフェイスを受け取る出力ポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// rtm.dll
#include <windows.h>
INT CreateTable(
GUID* lpInterface,
LPALLOCATEBUFFER lpAllocateBuffer,
LPALLOCATEMORE lpAllocateMore,
LPFREEBUFFER lpFreeBuffer,
void* lpvReserved,
DWORD ulTableType,
DWORD ulPropTagIndexColumn,
SPropTagArray* lpSPropTagArrayColumns,
ITableData** lppTableData
);[DllImport("rtm.dll", ExactSpelling = true)]
static extern int CreateTable(
ref Guid lpInterface, // GUID* in/out
IntPtr lpAllocateBuffer, // LPALLOCATEBUFFER
IntPtr lpAllocateMore, // LPALLOCATEMORE
IntPtr lpFreeBuffer, // LPFREEBUFFER
IntPtr lpvReserved, // void* in/out
uint ulTableType, // DWORD
uint ulPropTagIndexColumn, // DWORD
IntPtr lpSPropTagArrayColumns, // SPropTagArray* in/out
IntPtr lppTableData // ITableData** out
);<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function CreateTable(
ByRef lpInterface As Guid, ' GUID* in/out
lpAllocateBuffer As IntPtr, ' LPALLOCATEBUFFER
lpAllocateMore As IntPtr, ' LPALLOCATEMORE
lpFreeBuffer As IntPtr, ' LPFREEBUFFER
lpvReserved As IntPtr, ' void* in/out
ulTableType As UInteger, ' DWORD
ulPropTagIndexColumn As UInteger, ' DWORD
lpSPropTagArrayColumns As IntPtr, ' SPropTagArray* in/out
lppTableData As IntPtr ' ITableData** out
) As Integer
End Function' lpInterface : GUID* in/out
' lpAllocateBuffer : LPALLOCATEBUFFER
' lpAllocateMore : LPALLOCATEMORE
' lpFreeBuffer : LPFREEBUFFER
' lpvReserved : void* in/out
' ulTableType : DWORD
' ulPropTagIndexColumn : DWORD
' lpSPropTagArrayColumns : SPropTagArray* in/out
' lppTableData : ITableData** out
Declare PtrSafe Function CreateTable Lib "rtm" ( _
ByVal lpInterface As LongPtr, _
ByVal lpAllocateBuffer As LongPtr, _
ByVal lpAllocateMore As LongPtr, _
ByVal lpFreeBuffer As LongPtr, _
ByVal lpvReserved As LongPtr, _
ByVal ulTableType As Long, _
ByVal ulPropTagIndexColumn As Long, _
ByVal lpSPropTagArrayColumns As LongPtr, _
ByVal lppTableData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateTable = ctypes.windll.rtm.CreateTable
CreateTable.restype = ctypes.c_int
CreateTable.argtypes = [
ctypes.c_void_p, # lpInterface : GUID* in/out
ctypes.c_void_p, # lpAllocateBuffer : LPALLOCATEBUFFER
ctypes.c_void_p, # lpAllocateMore : LPALLOCATEMORE
ctypes.c_void_p, # lpFreeBuffer : LPFREEBUFFER
ctypes.POINTER(None), # lpvReserved : void* in/out
wintypes.DWORD, # ulTableType : DWORD
wintypes.DWORD, # ulPropTagIndexColumn : DWORD
ctypes.c_void_p, # lpSPropTagArrayColumns : SPropTagArray* in/out
ctypes.c_void_p, # lppTableData : ITableData** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('rtm.dll')
CreateTable = Fiddle::Function.new(
lib['CreateTable'],
[
Fiddle::TYPE_VOIDP, # lpInterface : GUID* in/out
Fiddle::TYPE_VOIDP, # lpAllocateBuffer : LPALLOCATEBUFFER
Fiddle::TYPE_VOIDP, # lpAllocateMore : LPALLOCATEMORE
Fiddle::TYPE_VOIDP, # lpFreeBuffer : LPFREEBUFFER
Fiddle::TYPE_VOIDP, # lpvReserved : void* in/out
-Fiddle::TYPE_INT, # ulTableType : DWORD
-Fiddle::TYPE_INT, # ulPropTagIndexColumn : DWORD
Fiddle::TYPE_VOIDP, # lpSPropTagArrayColumns : SPropTagArray* in/out
Fiddle::TYPE_VOIDP, # lppTableData : ITableData** out
],
Fiddle::TYPE_INT)#[link(name = "rtm")]
extern "system" {
fn CreateTable(
lpInterface: *mut GUID, // GUID* in/out
lpAllocateBuffer: *const core::ffi::c_void, // LPALLOCATEBUFFER
lpAllocateMore: *const core::ffi::c_void, // LPALLOCATEMORE
lpFreeBuffer: *const core::ffi::c_void, // LPFREEBUFFER
lpvReserved: *mut (), // void* in/out
ulTableType: u32, // DWORD
ulPropTagIndexColumn: u32, // DWORD
lpSPropTagArrayColumns: *mut SPropTagArray, // SPropTagArray* in/out
lppTableData: *mut *mut core::ffi::c_void // ITableData** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("rtm.dll")]
public static extern int CreateTable(ref Guid lpInterface, IntPtr lpAllocateBuffer, IntPtr lpAllocateMore, IntPtr lpFreeBuffer, IntPtr lpvReserved, uint ulTableType, uint ulPropTagIndexColumn, IntPtr lpSPropTagArrayColumns, IntPtr lppTableData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtm_CreateTable' -Namespace Win32 -PassThru
# $api::CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)#uselib "rtm.dll"
#func global CreateTable "CreateTable" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateTable varptr(lpInterface), lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, varptr(lpSPropTagArrayColumns), lppTableData ; 戻り値は stat
; lpInterface : GUID* in/out -> "sptr"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpAllocateMore : LPALLOCATEMORE -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpvReserved : void* in/out -> "sptr"
; ulTableType : DWORD -> "sptr"
; ulPropTagIndexColumn : DWORD -> "sptr"
; lpSPropTagArrayColumns : SPropTagArray* in/out -> "sptr"
; lppTableData : ITableData** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "rtm.dll" #cfunc global CreateTable "CreateTable" var, sptr, sptr, sptr, sptr, int, int, var, sptr ; res = CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData) ; lpInterface : GUID* in/out -> "var" ; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr" ; lpAllocateMore : LPALLOCATEMORE -> "sptr" ; lpFreeBuffer : LPFREEBUFFER -> "sptr" ; lpvReserved : void* in/out -> "sptr" ; ulTableType : DWORD -> "int" ; ulPropTagIndexColumn : DWORD -> "int" ; lpSPropTagArrayColumns : SPropTagArray* in/out -> "var" ; lppTableData : ITableData** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "rtm.dll" #cfunc global CreateTable "CreateTable" sptr, sptr, sptr, sptr, sptr, int, int, sptr, sptr ; res = CreateTable(varptr(lpInterface), lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, varptr(lpSPropTagArrayColumns), lppTableData) ; lpInterface : GUID* in/out -> "sptr" ; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr" ; lpAllocateMore : LPALLOCATEMORE -> "sptr" ; lpFreeBuffer : LPFREEBUFFER -> "sptr" ; lpvReserved : void* in/out -> "sptr" ; ulTableType : DWORD -> "int" ; ulPropTagIndexColumn : DWORD -> "int" ; lpSPropTagArrayColumns : SPropTagArray* in/out -> "sptr" ; lppTableData : ITableData** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT CreateTable(GUID* lpInterface, LPALLOCATEBUFFER lpAllocateBuffer, LPALLOCATEMORE lpAllocateMore, LPFREEBUFFER lpFreeBuffer, void* lpvReserved, DWORD ulTableType, DWORD ulPropTagIndexColumn, SPropTagArray* lpSPropTagArrayColumns, ITableData** lppTableData) #uselib "rtm.dll" #cfunc global CreateTable "CreateTable" var, intptr, intptr, intptr, intptr, int, int, var, intptr ; res = CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData) ; lpInterface : GUID* in/out -> "var" ; lpAllocateBuffer : LPALLOCATEBUFFER -> "intptr" ; lpAllocateMore : LPALLOCATEMORE -> "intptr" ; lpFreeBuffer : LPFREEBUFFER -> "intptr" ; lpvReserved : void* in/out -> "intptr" ; ulTableType : DWORD -> "int" ; ulPropTagIndexColumn : DWORD -> "int" ; lpSPropTagArrayColumns : SPropTagArray* in/out -> "var" ; lppTableData : ITableData** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT CreateTable(GUID* lpInterface, LPALLOCATEBUFFER lpAllocateBuffer, LPALLOCATEMORE lpAllocateMore, LPFREEBUFFER lpFreeBuffer, void* lpvReserved, DWORD ulTableType, DWORD ulPropTagIndexColumn, SPropTagArray* lpSPropTagArrayColumns, ITableData** lppTableData) #uselib "rtm.dll" #cfunc global CreateTable "CreateTable" intptr, intptr, intptr, intptr, intptr, int, int, intptr, intptr ; res = CreateTable(varptr(lpInterface), lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, varptr(lpSPropTagArrayColumns), lppTableData) ; lpInterface : GUID* in/out -> "intptr" ; lpAllocateBuffer : LPALLOCATEBUFFER -> "intptr" ; lpAllocateMore : LPALLOCATEMORE -> "intptr" ; lpFreeBuffer : LPFREEBUFFER -> "intptr" ; lpvReserved : void* in/out -> "intptr" ; ulTableType : DWORD -> "int" ; ulPropTagIndexColumn : DWORD -> "int" ; lpSPropTagArrayColumns : SPropTagArray* in/out -> "intptr" ; lppTableData : ITableData** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rtm = windows.NewLazySystemDLL("rtm.dll")
procCreateTable = rtm.NewProc("CreateTable")
)
// lpInterface (GUID* in/out), lpAllocateBuffer (LPALLOCATEBUFFER), lpAllocateMore (LPALLOCATEMORE), lpFreeBuffer (LPFREEBUFFER), lpvReserved (void* in/out), ulTableType (DWORD), ulPropTagIndexColumn (DWORD), lpSPropTagArrayColumns (SPropTagArray* in/out), lppTableData (ITableData** out)
r1, _, err := procCreateTable.Call(
uintptr(lpInterface),
uintptr(lpAllocateBuffer),
uintptr(lpAllocateMore),
uintptr(lpFreeBuffer),
uintptr(lpvReserved),
uintptr(ulTableType),
uintptr(ulPropTagIndexColumn),
uintptr(lpSPropTagArrayColumns),
uintptr(lppTableData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction CreateTable(
lpInterface: PGUID; // GUID* in/out
lpAllocateBuffer: Pointer; // LPALLOCATEBUFFER
lpAllocateMore: Pointer; // LPALLOCATEMORE
lpFreeBuffer: Pointer; // LPFREEBUFFER
lpvReserved: Pointer; // void* in/out
ulTableType: DWORD; // DWORD
ulPropTagIndexColumn: DWORD; // DWORD
lpSPropTagArrayColumns: Pointer; // SPropTagArray* in/out
lppTableData: Pointer // ITableData** out
): Integer; stdcall;
external 'rtm.dll' name 'CreateTable';result := DllCall("rtm\CreateTable"
, "Ptr", lpInterface ; GUID* in/out
, "Ptr", lpAllocateBuffer ; LPALLOCATEBUFFER
, "Ptr", lpAllocateMore ; LPALLOCATEMORE
, "Ptr", lpFreeBuffer ; LPFREEBUFFER
, "Ptr", lpvReserved ; void* in/out
, "UInt", ulTableType ; DWORD
, "UInt", ulPropTagIndexColumn ; DWORD
, "Ptr", lpSPropTagArrayColumns ; SPropTagArray* in/out
, "Ptr", lppTableData ; ITableData** out
, "Int") ; return: INT●CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData) = DLL("rtm.dll", "int CreateTable(void*, void*, void*, void*, void*, dword, dword, void*, void*)")
# 呼び出し: CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)
# lpInterface : GUID* in/out -> "void*"
# lpAllocateBuffer : LPALLOCATEBUFFER -> "void*"
# lpAllocateMore : LPALLOCATEMORE -> "void*"
# lpFreeBuffer : LPFREEBUFFER -> "void*"
# lpvReserved : void* in/out -> "void*"
# ulTableType : DWORD -> "dword"
# ulPropTagIndexColumn : DWORD -> "dword"
# lpSPropTagArrayColumns : SPropTagArray* in/out -> "void*"
# lppTableData : ITableData** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rtm" fn CreateTable(
lpInterface: [*c]GUID, // GUID* in/out
lpAllocateBuffer: ?*anyopaque, // LPALLOCATEBUFFER
lpAllocateMore: ?*anyopaque, // LPALLOCATEMORE
lpFreeBuffer: ?*anyopaque, // LPFREEBUFFER
lpvReserved: ?*anyopaque, // void* in/out
ulTableType: u32, // DWORD
ulPropTagIndexColumn: u32, // DWORD
lpSPropTagArrayColumns: [*c]SPropTagArray, // SPropTagArray* in/out
lppTableData: ?*anyopaque // ITableData** out
) callconv(std.os.windows.WINAPI) i32;proc CreateTable(
lpInterface: ptr GUID, # GUID* in/out
lpAllocateBuffer: pointer, # LPALLOCATEBUFFER
lpAllocateMore: pointer, # LPALLOCATEMORE
lpFreeBuffer: pointer, # LPFREEBUFFER
lpvReserved: pointer, # void* in/out
ulTableType: uint32, # DWORD
ulPropTagIndexColumn: uint32, # DWORD
lpSPropTagArrayColumns: ptr SPropTagArray, # SPropTagArray* in/out
lppTableData: pointer # ITableData** out
): int32 {.importc: "CreateTable", stdcall, dynlib: "rtm.dll".}pragma(lib, "rtm");
extern(Windows)
int CreateTable(
GUID* lpInterface, // GUID* in/out
void* lpAllocateBuffer, // LPALLOCATEBUFFER
void* lpAllocateMore, // LPALLOCATEMORE
void* lpFreeBuffer, // LPFREEBUFFER
void* lpvReserved, // void* in/out
uint ulTableType, // DWORD
uint ulPropTagIndexColumn, // DWORD
SPropTagArray* lpSPropTagArrayColumns, // SPropTagArray* in/out
void* lppTableData // ITableData** out
);ccall((:CreateTable, "rtm.dll"), stdcall, Int32,
(Ptr{GUID}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, UInt32, UInt32, Ptr{SPropTagArray}, Ptr{Cvoid}),
lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)
# lpInterface : GUID* in/out -> Ptr{GUID}
# lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr{Cvoid}
# lpAllocateMore : LPALLOCATEMORE -> Ptr{Cvoid}
# lpFreeBuffer : LPFREEBUFFER -> Ptr{Cvoid}
# lpvReserved : void* in/out -> Ptr{Cvoid}
# ulTableType : DWORD -> UInt32
# ulPropTagIndexColumn : DWORD -> UInt32
# lpSPropTagArrayColumns : SPropTagArray* in/out -> Ptr{SPropTagArray}
# lppTableData : ITableData** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CreateTable(
void* lpInterface,
void* lpAllocateBuffer,
void* lpAllocateMore,
void* lpFreeBuffer,
void* lpvReserved,
uint32_t ulTableType,
uint32_t ulPropTagIndexColumn,
void* lpSPropTagArrayColumns,
void* lppTableData);
]]
local rtm = ffi.load("rtm")
-- rtm.CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)
-- lpInterface : GUID* in/out
-- lpAllocateBuffer : LPALLOCATEBUFFER
-- lpAllocateMore : LPALLOCATEMORE
-- lpFreeBuffer : LPFREEBUFFER
-- lpvReserved : void* in/out
-- ulTableType : DWORD
-- ulPropTagIndexColumn : DWORD
-- lpSPropTagArrayColumns : SPropTagArray* in/out
-- lppTableData : ITableData** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('rtm.dll');
const CreateTable = lib.func('__stdcall', 'CreateTable', 'int32_t', ['void *', 'void *', 'void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'void *', 'void *']);
// CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)
// lpInterface : GUID* in/out -> 'void *'
// lpAllocateBuffer : LPALLOCATEBUFFER -> 'void *'
// lpAllocateMore : LPALLOCATEMORE -> 'void *'
// lpFreeBuffer : LPFREEBUFFER -> 'void *'
// lpvReserved : void* in/out -> 'void *'
// ulTableType : DWORD -> 'uint32_t'
// ulPropTagIndexColumn : DWORD -> 'uint32_t'
// lpSPropTagArrayColumns : SPropTagArray* in/out -> 'void *'
// lppTableData : ITableData** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("rtm.dll", {
CreateTable: { parameters: ["pointer", "pointer", "pointer", "pointer", "pointer", "u32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData)
// lpInterface : GUID* in/out -> "pointer"
// lpAllocateBuffer : LPALLOCATEBUFFER -> "pointer"
// lpAllocateMore : LPALLOCATEMORE -> "pointer"
// lpFreeBuffer : LPFREEBUFFER -> "pointer"
// lpvReserved : void* in/out -> "pointer"
// ulTableType : DWORD -> "u32"
// ulPropTagIndexColumn : DWORD -> "u32"
// lpSPropTagArrayColumns : SPropTagArray* in/out -> "pointer"
// lppTableData : ITableData** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CreateTable(
void* lpInterface,
void* lpAllocateBuffer,
void* lpAllocateMore,
void* lpFreeBuffer,
void* lpvReserved,
uint32_t ulTableType,
uint32_t ulPropTagIndexColumn,
void* lpSPropTagArrayColumns,
void* lppTableData);
C, "rtm.dll");
// $ffi->CreateTable(lpInterface, lpAllocateBuffer, lpAllocateMore, lpFreeBuffer, lpvReserved, ulTableType, ulPropTagIndexColumn, lpSPropTagArrayColumns, lppTableData);
// lpInterface : GUID* in/out
// lpAllocateBuffer : LPALLOCATEBUFFER
// lpAllocateMore : LPALLOCATEMORE
// lpFreeBuffer : LPFREEBUFFER
// lpvReserved : void* in/out
// ulTableType : DWORD
// ulPropTagIndexColumn : DWORD
// lpSPropTagArrayColumns : SPropTagArray* in/out
// lppTableData : 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 Rtm extends StdCallLibrary {
Rtm INSTANCE = Native.load("rtm", Rtm.class);
int CreateTable(
Pointer lpInterface, // GUID* in/out
Callback lpAllocateBuffer, // LPALLOCATEBUFFER
Callback lpAllocateMore, // LPALLOCATEMORE
Callback lpFreeBuffer, // LPFREEBUFFER
Pointer lpvReserved, // void* in/out
int ulTableType, // DWORD
int ulPropTagIndexColumn, // DWORD
Pointer lpSPropTagArrayColumns, // SPropTagArray* in/out
Pointer lppTableData // ITableData** out
);
}@[Link("rtm")]
lib Librtm
fun CreateTable = CreateTable(
lpInterface : GUID*, # GUID* in/out
lpAllocateBuffer : Void*, # LPALLOCATEBUFFER
lpAllocateMore : Void*, # LPALLOCATEMORE
lpFreeBuffer : Void*, # LPFREEBUFFER
lpvReserved : Void*, # void* in/out
ulTableType : UInt32, # DWORD
ulPropTagIndexColumn : UInt32, # DWORD
lpSPropTagArrayColumns : SPropTagArray*, # SPropTagArray* in/out
lppTableData : 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 CreateTableNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef CreateTableDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>);
final CreateTable = DynamicLibrary.open('rtm.dll')
.lookupFunction<CreateTableNative, CreateTableDart>('CreateTable');
// lpInterface : GUID* in/out -> Pointer<Void>
// lpAllocateBuffer : LPALLOCATEBUFFER -> Pointer<Void>
// lpAllocateMore : LPALLOCATEMORE -> Pointer<Void>
// lpFreeBuffer : LPFREEBUFFER -> Pointer<Void>
// lpvReserved : void* in/out -> Pointer<Void>
// ulTableType : DWORD -> Uint32
// ulPropTagIndexColumn : DWORD -> Uint32
// lpSPropTagArrayColumns : SPropTagArray* in/out -> Pointer<Void>
// lppTableData : ITableData** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateTable(
lpInterface: PGUID; // GUID* in/out
lpAllocateBuffer: Pointer; // LPALLOCATEBUFFER
lpAllocateMore: Pointer; // LPALLOCATEMORE
lpFreeBuffer: Pointer; // LPFREEBUFFER
lpvReserved: Pointer; // void* in/out
ulTableType: DWORD; // DWORD
ulPropTagIndexColumn: DWORD; // DWORD
lpSPropTagArrayColumns: Pointer; // SPropTagArray* in/out
lppTableData: Pointer // ITableData** out
): Integer; stdcall;
external 'rtm.dll' name 'CreateTable';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateTable"
c_CreateTable :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- lpInterface : GUID* in/out -> Ptr ()
-- lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr ()
-- lpAllocateMore : LPALLOCATEMORE -> Ptr ()
-- lpFreeBuffer : LPFREEBUFFER -> Ptr ()
-- lpvReserved : void* in/out -> Ptr ()
-- ulTableType : DWORD -> Word32
-- ulPropTagIndexColumn : DWORD -> Word32
-- lpSPropTagArrayColumns : SPropTagArray* in/out -> Ptr ()
-- lppTableData : ITableData** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createtable =
foreign "CreateTable"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* lpInterface : GUID* in/out -> (ptr void) *)
(* lpAllocateBuffer : LPALLOCATEBUFFER -> (ptr void) *)
(* lpAllocateMore : LPALLOCATEMORE -> (ptr void) *)
(* lpFreeBuffer : LPFREEBUFFER -> (ptr void) *)
(* lpvReserved : void* in/out -> (ptr void) *)
(* ulTableType : DWORD -> uint32_t *)
(* ulPropTagIndexColumn : DWORD -> uint32_t *)
(* lpSPropTagArrayColumns : SPropTagArray* in/out -> (ptr void) *)
(* lppTableData : ITableData** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rtm (t "rtm.dll"))
(cffi:use-foreign-library rtm)
(cffi:defcfun ("CreateTable" create-table :convention :stdcall) :int32
(lp-interface :pointer) ; GUID* in/out
(lp-allocate-buffer :pointer) ; LPALLOCATEBUFFER
(lp-allocate-more :pointer) ; LPALLOCATEMORE
(lp-free-buffer :pointer) ; LPFREEBUFFER
(lpv-reserved :pointer) ; void* in/out
(ul-table-type :uint32) ; DWORD
(ul-prop-tag-index-column :uint32) ; DWORD
(lp-sprop-tag-array-columns :pointer) ; SPropTagArray* in/out
(lpp-table-data :pointer)) ; ITableData** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateTable = Win32::API::More->new('rtm',
'int CreateTable(LPVOID lpInterface, LPVOID lpAllocateBuffer, LPVOID lpAllocateMore, LPVOID lpFreeBuffer, LPVOID lpvReserved, DWORD ulTableType, DWORD ulPropTagIndexColumn, LPVOID lpSPropTagArrayColumns, LPVOID lppTableData)');
# my $ret = $CreateTable->Call($lpInterface, $lpAllocateBuffer, $lpAllocateMore, $lpFreeBuffer, $lpvReserved, $ulTableType, $ulPropTagIndexColumn, $lpSPropTagArrayColumns, $lppTableData);
# lpInterface : GUID* in/out -> LPVOID
# lpAllocateBuffer : LPALLOCATEBUFFER -> LPVOID
# lpAllocateMore : LPALLOCATEMORE -> LPVOID
# lpFreeBuffer : LPFREEBUFFER -> LPVOID
# lpvReserved : void* in/out -> LPVOID
# ulTableType : DWORD -> DWORD
# ulPropTagIndexColumn : DWORD -> DWORD
# lpSPropTagArrayColumns : SPropTagArray* in/out -> LPVOID
# lppTableData : ITableData** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。