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

HrAddColumns

関数
MAPIテーブルへ新しい列(プロパティ)を追加する。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

HRESULT HrAddColumns(
    IMAPITable* lptbl,
    SPropTagArray* lpproptagColumnsNew,
    LPALLOCATEBUFFER lpAllocateBuffer,
    LPFREEBUFFER lpFreeBuffer
);

パラメーター

名前方向説明
lptblIMAPITable*in列を追加する対象のIMAPITableインターフェイスへのポインタ。
lpproptagColumnsNewSPropTagArray*inout追加する列のプロパティタグを並べたSPropTagArrayへのポインタ。
lpAllocateBufferLPALLOCATEBUFFERinメモリ確保に用いるAllocateBuffer関数へのポインタ。
lpFreeBufferLPFREEBUFFERin確保したメモリを解放するFreeBuffer関数へのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

HrAddColumns = ctypes.windll.mapi32.HrAddColumns
HrAddColumns.restype = ctypes.c_int
HrAddColumns.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
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procHrAddColumns = mapi32.NewProc("HrAddColumns")
)

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

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

typedef HrAddColumnsNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef HrAddColumnsDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final HrAddColumns = DynamicLibrary.open('MAPI32.dll')
    .lookupFunction<HrAddColumnsNative, HrAddColumnsDart>('HrAddColumns');
// lptbl : IMAPITable* -> Pointer<Void>
// lpproptagColumnsNew : SPropTagArray* in/out -> Pointer<Void>
// lpAllocateBuffer : LPALLOCATEBUFFER -> Pointer<Void>
// lpFreeBuffer : LPFREEBUFFER -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HrAddColumns(
  lptbl: Pointer;   // IMAPITable*
  lpproptagColumnsNew: Pointer;   // SPropTagArray* in/out
  lpAllocateBuffer: Pointer;   // LPALLOCATEBUFFER
  lpFreeBuffer: Pointer   // LPFREEBUFFER
): Integer; stdcall;
  external 'MAPI32.dll' name 'HrAddColumns';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HrAddColumns"
  c_HrAddColumns :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- lptbl : IMAPITable* -> Ptr ()
-- lpproptagColumnsNew : SPropTagArray* in/out -> Ptr ()
-- lpAllocateBuffer : LPALLOCATEBUFFER -> Ptr ()
-- lpFreeBuffer : LPFREEBUFFER -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hraddcolumns =
  foreign "HrAddColumns"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* lptbl : IMAPITable* -> (ptr void) *)
(* lpproptagColumnsNew : SPropTagArray* in/out -> (ptr void) *)
(* lpAllocateBuffer : LPALLOCATEBUFFER -> (ptr void) *)
(* lpFreeBuffer : LPFREEBUFFER -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mapi32 (t "MAPI32.dll"))
(cffi:use-foreign-library mapi32)

(cffi:defcfun ("HrAddColumns" hr-add-columns :convention :stdcall) :int32
  (lptbl :pointer)   ; IMAPITable*
  (lpproptag-columns-new :pointer)   ; SPropTagArray* in/out
  (lp-allocate-buffer :pointer)   ; LPALLOCATEBUFFER
  (lp-free-buffer :pointer))   ; LPFREEBUFFER
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HrAddColumns = Win32::API::More->new('MAPI32',
    'int HrAddColumns(LPVOID lptbl, LPVOID lpproptagColumnsNew, LPVOID lpAllocateBuffer, LPVOID lpFreeBuffer)');
# my $ret = $HrAddColumns->Call($lptbl, $lpproptagColumnsNew, $lpAllocateBuffer, $lpFreeBuffer);
# lptbl : IMAPITable* -> LPVOID
# lpproptagColumnsNew : SPropTagArray* in/out -> LPVOID
# lpAllocateBuffer : LPALLOCATEBUFFER -> LPVOID
# lpFreeBuffer : LPFREEBUFFER -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

類似 API
使用する型