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

HrQueryAllRows

関数
MAPIテーブルから条件に合う全行を一括取得する。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

HRESULT HrQueryAllRows(
    IMAPITable* lpTable,
    SPropTagArray* lpPropTags,
    SRestriction* lpRestriction,
    SSortOrderSet* lpSortOrderSet,
    INT crowsMax,
    SRowSet** lppRows
);

パラメーター

名前方向説明
lpTableIMAPITable*in全行を取得する対象のIMAPITableインターフェイスへのポインタ。
lpPropTagsSPropTagArray*inout取得する列を指定するSPropTagArrayへのポインタ。NULLで全列を取得する。
lpRestrictionSRestriction*inout行を絞り込む条件SRestriction構造体へのポインタ。NULLで全行が対象。
lpSortOrderSetSSortOrderSet*inout並べ替え順を指定するSSortOrderSet構造体へのポインタ。NULL可。
crowsMaxINTin取得する最大行数を示す整数。0で制限なし。
lppRowsSRowSet**inout取得した行セットSRowSetを受け取る出力ポインタ。FreeProwsで解放する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HrQueryAllRows(
    IMAPITable* lpTable,
    SPropTagArray* lpPropTags,
    SRestriction* lpRestriction,
    SSortOrderSet* lpSortOrderSet,
    INT crowsMax,
    SRowSet** lppRows
);
[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int HrQueryAllRows(
    IntPtr lpTable,   // IMAPITable*
    IntPtr lpPropTags,   // SPropTagArray* in/out
    IntPtr lpRestriction,   // SRestriction* in/out
    IntPtr lpSortOrderSet,   // SSortOrderSet* in/out
    int crowsMax,   // INT
    IntPtr lppRows   // SRowSet** in/out
);
<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function HrQueryAllRows(
    lpTable As IntPtr,   ' IMAPITable*
    lpPropTags As IntPtr,   ' SPropTagArray* in/out
    lpRestriction As IntPtr,   ' SRestriction* in/out
    lpSortOrderSet As IntPtr,   ' SSortOrderSet* in/out
    crowsMax As Integer,   ' INT
    lppRows As IntPtr   ' SRowSet** in/out
) As Integer
End Function
' lpTable : IMAPITable*
' lpPropTags : SPropTagArray* in/out
' lpRestriction : SRestriction* in/out
' lpSortOrderSet : SSortOrderSet* in/out
' crowsMax : INT
' lppRows : SRowSet** in/out
Declare PtrSafe Function HrQueryAllRows Lib "mapi32" ( _
    ByVal lpTable As LongPtr, _
    ByVal lpPropTags As LongPtr, _
    ByVal lpRestriction As LongPtr, _
    ByVal lpSortOrderSet As LongPtr, _
    ByVal crowsMax As Long, _
    ByVal lppRows As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HrQueryAllRows = ctypes.windll.mapi32.HrQueryAllRows
HrQueryAllRows.restype = ctypes.c_int
HrQueryAllRows.argtypes = [
    ctypes.c_void_p,  # lpTable : IMAPITable*
    ctypes.c_void_p,  # lpPropTags : SPropTagArray* in/out
    ctypes.c_void_p,  # lpRestriction : SRestriction* in/out
    ctypes.c_void_p,  # lpSortOrderSet : SSortOrderSet* in/out
    ctypes.c_int,  # crowsMax : INT
    ctypes.c_void_p,  # lppRows : SRowSet** in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procHrQueryAllRows = mapi32.NewProc("HrQueryAllRows")
)

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

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

typedef HrQueryAllRowsNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Int32, Pointer<Void>);
typedef HrQueryAllRowsDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final HrQueryAllRows = DynamicLibrary.open('MAPI32.dll')
    .lookupFunction<HrQueryAllRowsNative, HrQueryAllRowsDart>('HrQueryAllRows');
// lpTable : IMAPITable* -> Pointer<Void>
// lpPropTags : SPropTagArray* in/out -> Pointer<Void>
// lpRestriction : SRestriction* in/out -> Pointer<Void>
// lpSortOrderSet : SSortOrderSet* in/out -> Pointer<Void>
// crowsMax : INT -> Int32
// lppRows : SRowSet** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HrQueryAllRows(
  lpTable: Pointer;   // IMAPITable*
  lpPropTags: Pointer;   // SPropTagArray* in/out
  lpRestriction: Pointer;   // SRestriction* in/out
  lpSortOrderSet: Pointer;   // SSortOrderSet* in/out
  crowsMax: Integer;   // INT
  lppRows: Pointer   // SRowSet** in/out
): Integer; stdcall;
  external 'MAPI32.dll' name 'HrQueryAllRows';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HrQueryAllRows"
  c_HrQueryAllRows :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> Int32 -> Ptr () -> IO Int32
-- lpTable : IMAPITable* -> Ptr ()
-- lpPropTags : SPropTagArray* in/out -> Ptr ()
-- lpRestriction : SRestriction* in/out -> Ptr ()
-- lpSortOrderSet : SSortOrderSet* in/out -> Ptr ()
-- crowsMax : INT -> Int32
-- lppRows : SRowSet** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hrqueryallrows =
  foreign "HrQueryAllRows"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* lpTable : IMAPITable* -> (ptr void) *)
(* lpPropTags : SPropTagArray* in/out -> (ptr void) *)
(* lpRestriction : SRestriction* in/out -> (ptr void) *)
(* lpSortOrderSet : SSortOrderSet* in/out -> (ptr void) *)
(* crowsMax : INT -> int32_t *)
(* lppRows : SRowSet** in/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 ("HrQueryAllRows" hr-query-all-rows :convention :stdcall) :int32
  (lp-table :pointer)   ; IMAPITable*
  (lp-prop-tags :pointer)   ; SPropTagArray* in/out
  (lp-restriction :pointer)   ; SRestriction* in/out
  (lp-sort-order-set :pointer)   ; SSortOrderSet* in/out
  (crows-max :int32)   ; INT
  (lpp-rows :pointer))   ; SRowSet** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HrQueryAllRows = Win32::API::More->new('MAPI32',
    'int HrQueryAllRows(LPVOID lpTable, LPVOID lpPropTags, LPVOID lpRestriction, LPVOID lpSortOrderSet, int crowsMax, LPVOID lppRows)');
# my $ret = $HrQueryAllRows->Call($lpTable, $lpPropTags, $lpRestriction, $lpSortOrderSet, $crowsMax, $lppRows);
# lpTable : IMAPITable* -> LPVOID
# lpPropTags : SPropTagArray* in/out -> LPVOID
# lpRestriction : SRestriction* in/out -> LPVOID
# lpSortOrderSet : SSortOrderSet* in/out -> LPVOID
# crowsMax : INT -> int
# lppRows : SRowSet** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型