ホーム › System.AddressBook › ScCountProps
ScCountProps
関数プロパティ値配列のシリアライズに必要なバイト数を計算する。
シグネチャ
// MAPI32.dll
#include <windows.h>
INT ScCountProps(
INT cValues,
SPropValue* lpPropArray,
DWORD* lpcb
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| cValues | INT | in | lpPropArrayに含まれるプロパティ値の件数を示す整数。 |
| lpPropArray | SPropValue* | inout | サイズを計算する対象のSPropValue構造体配列へのポインタ。 |
| lpcb | DWORD* | inout | 格納に必要なバイト数を返すDWORDポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// MAPI32.dll
#include <windows.h>
INT ScCountProps(
INT cValues,
SPropValue* lpPropArray,
DWORD* lpcb
);[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int ScCountProps(
int cValues, // INT
IntPtr lpPropArray, // SPropValue* in/out
ref uint lpcb // DWORD* in/out
);<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function ScCountProps(
cValues As Integer, ' INT
lpPropArray As IntPtr, ' SPropValue* in/out
ByRef lpcb As UInteger ' DWORD* in/out
) As Integer
End Function' cValues : INT
' lpPropArray : SPropValue* in/out
' lpcb : DWORD* in/out
Declare PtrSafe Function ScCountProps Lib "mapi32" ( _
ByVal cValues As Long, _
ByVal lpPropArray As LongPtr, _
ByRef lpcb As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScCountProps = ctypes.windll.mapi32.ScCountProps
ScCountProps.restype = ctypes.c_int
ScCountProps.argtypes = [
ctypes.c_int, # cValues : INT
ctypes.c_void_p, # lpPropArray : SPropValue* in/out
ctypes.POINTER(wintypes.DWORD), # lpcb : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MAPI32.dll')
ScCountProps = Fiddle::Function.new(
lib['ScCountProps'],
[
Fiddle::TYPE_INT, # cValues : INT
Fiddle::TYPE_VOIDP, # lpPropArray : SPropValue* in/out
Fiddle::TYPE_VOIDP, # lpcb : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "mapi32")]
extern "system" {
fn ScCountProps(
cValues: i32, // INT
lpPropArray: *mut SPropValue, // SPropValue* in/out
lpcb: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MAPI32.dll")]
public static extern int ScCountProps(int cValues, IntPtr lpPropArray, ref uint lpcb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MAPI32_ScCountProps' -Namespace Win32 -PassThru
# $api::ScCountProps(cValues, lpPropArray, lpcb)#uselib "MAPI32.dll"
#func global ScCountProps "ScCountProps" sptr, sptr, sptr
; ScCountProps cValues, varptr(lpPropArray), varptr(lpcb) ; 戻り値は stat
; cValues : INT -> "sptr"
; lpPropArray : SPropValue* in/out -> "sptr"
; lpcb : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MAPI32.dll" #cfunc global ScCountProps "ScCountProps" int, var, var ; res = ScCountProps(cValues, lpPropArray, lpcb) ; cValues : INT -> "int" ; lpPropArray : SPropValue* in/out -> "var" ; lpcb : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MAPI32.dll" #cfunc global ScCountProps "ScCountProps" int, sptr, sptr ; res = ScCountProps(cValues, varptr(lpPropArray), varptr(lpcb)) ; cValues : INT -> "int" ; lpPropArray : SPropValue* in/out -> "sptr" ; lpcb : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ScCountProps(INT cValues, SPropValue* lpPropArray, DWORD* lpcb) #uselib "MAPI32.dll" #cfunc global ScCountProps "ScCountProps" int, var, var ; res = ScCountProps(cValues, lpPropArray, lpcb) ; cValues : INT -> "int" ; lpPropArray : SPropValue* in/out -> "var" ; lpcb : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ScCountProps(INT cValues, SPropValue* lpPropArray, DWORD* lpcb) #uselib "MAPI32.dll" #cfunc global ScCountProps "ScCountProps" int, intptr, intptr ; res = ScCountProps(cValues, varptr(lpPropArray), varptr(lpcb)) ; cValues : INT -> "int" ; lpPropArray : SPropValue* in/out -> "intptr" ; lpcb : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
procScCountProps = mapi32.NewProc("ScCountProps")
)
// cValues (INT), lpPropArray (SPropValue* in/out), lpcb (DWORD* in/out)
r1, _, err := procScCountProps.Call(
uintptr(cValues),
uintptr(lpPropArray),
uintptr(lpcb),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ScCountProps(
cValues: Integer; // INT
lpPropArray: Pointer; // SPropValue* in/out
lpcb: Pointer // DWORD* in/out
): Integer; stdcall;
external 'MAPI32.dll' name 'ScCountProps';result := DllCall("MAPI32\ScCountProps"
, "Int", cValues ; INT
, "Ptr", lpPropArray ; SPropValue* in/out
, "Ptr", lpcb ; DWORD* in/out
, "Int") ; return: INT●ScCountProps(cValues, lpPropArray, lpcb) = DLL("MAPI32.dll", "int ScCountProps(int, void*, void*)")
# 呼び出し: ScCountProps(cValues, lpPropArray, lpcb)
# cValues : INT -> "int"
# lpPropArray : SPropValue* in/out -> "void*"
# lpcb : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mapi32" fn ScCountProps(
cValues: i32, // INT
lpPropArray: [*c]SPropValue, // SPropValue* in/out
lpcb: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc ScCountProps(
cValues: int32, # INT
lpPropArray: ptr SPropValue, # SPropValue* in/out
lpcb: ptr uint32 # DWORD* in/out
): int32 {.importc: "ScCountProps", stdcall, dynlib: "MAPI32.dll".}pragma(lib, "mapi32");
extern(Windows)
int ScCountProps(
int cValues, // INT
SPropValue* lpPropArray, // SPropValue* in/out
uint* lpcb // DWORD* in/out
);ccall((:ScCountProps, "MAPI32.dll"), stdcall, Int32,
(Int32, Ptr{SPropValue}, Ptr{UInt32}),
cValues, lpPropArray, lpcb)
# cValues : INT -> Int32
# lpPropArray : SPropValue* in/out -> Ptr{SPropValue}
# lpcb : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScCountProps(
int32_t cValues,
void* lpPropArray,
uint32_t* lpcb);
]]
local mapi32 = ffi.load("mapi32")
-- mapi32.ScCountProps(cValues, lpPropArray, lpcb)
-- cValues : INT
-- lpPropArray : SPropValue* in/out
-- lpcb : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MAPI32.dll');
const ScCountProps = lib.func('__stdcall', 'ScCountProps', 'int32_t', ['int32_t', 'void *', 'uint32_t *']);
// ScCountProps(cValues, lpPropArray, lpcb)
// cValues : INT -> 'int32_t'
// lpPropArray : SPropValue* in/out -> 'void *'
// lpcb : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MAPI32.dll", {
ScCountProps: { parameters: ["i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ScCountProps(cValues, lpPropArray, lpcb)
// cValues : INT -> "i32"
// lpPropArray : SPropValue* in/out -> "pointer"
// lpcb : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScCountProps(
int32_t cValues,
void* lpPropArray,
uint32_t* lpcb);
C, "MAPI32.dll");
// $ffi->ScCountProps(cValues, lpPropArray, lpcb);
// cValues : INT
// lpPropArray : SPropValue* in/out
// lpcb : DWORD* 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 ScCountProps(
int cValues, // INT
Pointer lpPropArray, // SPropValue* in/out
IntByReference lpcb // DWORD* in/out
);
}@[Link("mapi32")]
lib LibMAPI32
fun ScCountProps = ScCountProps(
cValues : Int32, # INT
lpPropArray : SPropValue*, # SPropValue* in/out
lpcb : UInt32* # DWORD* 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 ScCountPropsNative = Int32 Function(Int32, Pointer<Void>, Pointer<Uint32>);
typedef ScCountPropsDart = int Function(int, Pointer<Void>, Pointer<Uint32>);
final ScCountProps = DynamicLibrary.open('MAPI32.dll')
.lookupFunction<ScCountPropsNative, ScCountPropsDart>('ScCountProps');
// cValues : INT -> Int32
// lpPropArray : SPropValue* in/out -> Pointer<Void>
// lpcb : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScCountProps(
cValues: Integer; // INT
lpPropArray: Pointer; // SPropValue* in/out
lpcb: Pointer // DWORD* in/out
): Integer; stdcall;
external 'MAPI32.dll' name 'ScCountProps';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScCountProps"
c_ScCountProps :: Int32 -> Ptr () -> Ptr Word32 -> IO Int32
-- cValues : INT -> Int32
-- lpPropArray : SPropValue* in/out -> Ptr ()
-- lpcb : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sccountprops =
foreign "ScCountProps"
(int32_t @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* cValues : INT -> int32_t *)
(* lpPropArray : SPropValue* in/out -> (ptr void) *)
(* lpcb : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mapi32 (t "MAPI32.dll"))
(cffi:use-foreign-library mapi32)
(cffi:defcfun ("ScCountProps" sc-count-props :convention :stdcall) :int32
(c-values :int32) ; INT
(lp-prop-array :pointer) ; SPropValue* in/out
(lpcb :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScCountProps = Win32::API::More->new('MAPI32',
'int ScCountProps(int cValues, LPVOID lpPropArray, LPVOID lpcb)');
# my $ret = $ScCountProps->Call($cValues, $lpPropArray, $lpcb);
# cValues : INT -> int
# lpPropArray : SPropValue* in/out -> LPVOID
# lpcb : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型