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

HrAddColumnsEx

関数
フィルタ関数を指定してMAPIテーブルへ列を追加する。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

HRESULT HrAddColumnsEx(
    IMAPITable* lptbl,
    SPropTagArray* lpproptagColumnsNew,
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPFREEBUFFER lpFreeBuffer,
    INT_PTR lpfnFilterColumns
);

パラメーター

名前方向
lptblIMAPITable*in
lpproptagColumnsNewSPropTagArray*inout
lpAllocateBufferLPALLOCATEBUFFERin
lpFreeBufferLPFREEBUFFERin
lpfnFilterColumnsINT_PTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HrAddColumnsEx(
    IMAPITable* lptbl,
    SPropTagArray* lpproptagColumnsNew,
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPFREEBUFFER lpFreeBuffer,
    INT_PTR lpfnFilterColumns
);
[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int HrAddColumnsEx(
    IntPtr lptbl,   // IMAPITable*
    IntPtr lpproptagColumnsNew,   // SPropTagArray* in/out
    IntPtr lpAllocateBuffer,   // LPALLOCATEBUFFER
    IntPtr lpFreeBuffer,   // LPFREEBUFFER
    IntPtr lpfnFilterColumns   // INT_PTR
);
<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function HrAddColumnsEx(
    lptbl As IntPtr,   ' IMAPITable*
    lpproptagColumnsNew As IntPtr,   ' SPropTagArray* in/out
    lpAllocateBuffer As IntPtr,   ' LPALLOCATEBUFFER
    lpFreeBuffer As IntPtr,   ' LPFREEBUFFER
    lpfnFilterColumns As IntPtr   ' INT_PTR
) As Integer
End Function
' lptbl : IMAPITable*
' lpproptagColumnsNew : SPropTagArray* in/out
' lpAllocateBuffer : LPALLOCATEBUFFER
' lpFreeBuffer : LPFREEBUFFER
' lpfnFilterColumns : INT_PTR
Declare PtrSafe Function HrAddColumnsEx Lib "mapi32" ( _
    ByVal lptbl As LongPtr, _
    ByVal lpproptagColumnsNew As LongPtr, _
    ByVal lpAllocateBuffer As LongPtr, _
    ByVal lpFreeBuffer As LongPtr, _
    ByVal lpfnFilterColumns As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HrAddColumnsEx = ctypes.windll.mapi32.HrAddColumnsEx
HrAddColumnsEx.restype = ctypes.c_int
HrAddColumnsEx.argtypes = [
    ctypes.c_void_p,  # lptbl : IMAPITable*
    ctypes.c_void_p,  # lpproptagColumnsNew : SPropTagArray* in/out
    ctypes.c_void_p,  # lpAllocateBuffer : LPALLOCATEBUFFER
    ctypes.c_void_p,  # lpFreeBuffer : LPFREEBUFFER
    ctypes.c_ssize_t,  # lpfnFilterColumns : INT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MAPI32.dll')
HrAddColumnsEx = Fiddle::Function.new(
  lib['HrAddColumnsEx'],
  [
    Fiddle::TYPE_VOIDP,  # lptbl : IMAPITable*
    Fiddle::TYPE_VOIDP,  # lpproptagColumnsNew : SPropTagArray* in/out
    Fiddle::TYPE_VOIDP,  # lpAllocateBuffer : LPALLOCATEBUFFER
    Fiddle::TYPE_VOIDP,  # lpFreeBuffer : LPFREEBUFFER
    Fiddle::TYPE_INTPTR_T,  # lpfnFilterColumns : INT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "mapi32")]
extern "system" {
    fn HrAddColumnsEx(
        lptbl: *mut core::ffi::c_void,  // IMAPITable*
        lpproptagColumnsNew: *mut SPropTagArray,  // SPropTagArray* in/out
        lpAllocateBuffer: *const core::ffi::c_void,  // LPALLOCATEBUFFER
        lpFreeBuffer: *const core::ffi::c_void,  // LPFREEBUFFER
        lpfnFilterColumns: isize  // INT_PTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MAPI32.dll")]
public static extern int HrAddColumnsEx(IntPtr lptbl, IntPtr lpproptagColumnsNew, IntPtr lpAllocateBuffer, IntPtr lpFreeBuffer, IntPtr lpfnFilterColumns);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MAPI32_HrAddColumnsEx' -Namespace Win32 -PassThru
# $api::HrAddColumnsEx(lptbl, lpproptagColumnsNew, lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns)
#uselib "MAPI32.dll"
#func global HrAddColumnsEx "HrAddColumnsEx" sptr, sptr, sptr, sptr, sptr
; HrAddColumnsEx lptbl, varptr(lpproptagColumnsNew), lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns   ; 戻り値は stat
; lptbl : IMAPITable* -> "sptr"
; lpproptagColumnsNew : SPropTagArray* in/out -> "sptr"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpfnFilterColumns : INT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MAPI32.dll"
#cfunc global HrAddColumnsEx "HrAddColumnsEx" sptr, var, sptr, sptr, sptr
; res = HrAddColumnsEx(lptbl, lpproptagColumnsNew, lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns)
; lptbl : IMAPITable* -> "sptr"
; lpproptagColumnsNew : SPropTagArray* in/out -> "var"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "sptr"
; lpFreeBuffer : LPFREEBUFFER -> "sptr"
; lpfnFilterColumns : INT_PTR -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT HrAddColumnsEx(IMAPITable* lptbl, SPropTagArray* lpproptagColumnsNew, LPALLOCATEBUFFER lpAllocateBuffer, LPFREEBUFFER lpFreeBuffer, INT_PTR lpfnFilterColumns)
#uselib "MAPI32.dll"
#cfunc global HrAddColumnsEx "HrAddColumnsEx" intptr, var, intptr, intptr, intptr
; res = HrAddColumnsEx(lptbl, lpproptagColumnsNew, lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns)
; lptbl : IMAPITable* -> "intptr"
; lpproptagColumnsNew : SPropTagArray* in/out -> "var"
; lpAllocateBuffer : LPALLOCATEBUFFER -> "intptr"
; lpFreeBuffer : LPFREEBUFFER -> "intptr"
; lpfnFilterColumns : INT_PTR -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procHrAddColumnsEx = mapi32.NewProc("HrAddColumnsEx")
)

// lptbl (IMAPITable*), lpproptagColumnsNew (SPropTagArray* in/out), lpAllocateBuffer (LPALLOCATEBUFFER), lpFreeBuffer (LPFREEBUFFER), lpfnFilterColumns (INT_PTR)
r1, _, err := procHrAddColumnsEx.Call(
	uintptr(lptbl),
	uintptr(lpproptagColumnsNew),
	uintptr(lpAllocateBuffer),
	uintptr(lpFreeBuffer),
	uintptr(lpfnFilterColumns),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HrAddColumnsEx(
  lptbl: Pointer;   // IMAPITable*
  lpproptagColumnsNew: Pointer;   // SPropTagArray* in/out
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpFreeBuffer: Pointer;   // LPFREEBUFFER
  lpfnFilterColumns: NativeInt   // INT_PTR
): Integer; stdcall;
  external 'MAPI32.dll' name 'HrAddColumnsEx';
result := DllCall("MAPI32\HrAddColumnsEx"
    , "Ptr", lptbl   ; IMAPITable*
    , "Ptr", lpproptagColumnsNew   ; SPropTagArray* in/out
    , "Ptr", lpAllocateBuffer   ; LPALLOCATEBUFFER
    , "Ptr", lpFreeBuffer   ; LPFREEBUFFER
    , "Ptr", lpfnFilterColumns   ; INT_PTR
    , "Int")   ; return: HRESULT
●HrAddColumnsEx(lptbl, lpproptagColumnsNew, lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns) = DLL("MAPI32.dll", "int HrAddColumnsEx(void*, void*, void*, void*, int)")
# 呼び出し: HrAddColumnsEx(lptbl, lpproptagColumnsNew, lpAllocateBuffer, lpFreeBuffer, lpfnFilterColumns)
# lptbl : IMAPITable* -> "void*"
# lpproptagColumnsNew : SPropTagArray* in/out -> "void*"
# lpAllocateBuffer : LPALLOCATEBUFFER -> "void*"
# lpFreeBuffer : LPFREEBUFFER -> "void*"
# lpfnFilterColumns : INT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。