ホーム › Globalization › MappingRecognizeText
MappingRecognizeText
関数ELSサービスを用いてテキストを解析・認識する。
シグネチャ
// elscore.dll
#include <windows.h>
HRESULT MappingRecognizeText(
MAPPING_SERVICE_INFO* pServiceInfo,
LPCWSTR pszText,
DWORD dwLength,
DWORD dwIndex,
MAPPING_OPTIONS* pOptions, // optional
MAPPING_PROPERTY_BAG* pbag
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pServiceInfo | MAPPING_SERVICE_INFO* | in | テキスト認識に使用するサービスに関する情報を含む MAPPING_SERVICE_INFO 構造体へのポインターです。この構造体は、以前に呼び出した MappingGetServices によって取得した構造体のいずれかである必要があります。このパラメーターを NULL に設定することはできません。 |
| pszText | LPCWSTR | in | 認識するテキストへのポインターです。テキストは UTF-16 である必要がありますが、一部のサービスには入力形式に関する追加の要件があります。このパラメーターを NULL に設定することはできません。 |
| dwLength | DWORD | in | pszText で指定したテキストの長さ(文字数)です。 |
| dwIndex | DWORD | in | サービスが使用する、指定したテキスト内のインデックスです。この値は 0 から dwLength-1 の範囲である必要があります。アプリケーションがテキスト全体を処理する場合は、このパラメーターを 0 に設定します。 |
| pOptions | MAPPING_OPTIONS* | inoptional | テキスト認識の結果と動作に影響するオプションを含む MAPPING_OPTIONS 構造体へのポインターです。アプリケーションは、すべての構造体メンバーに値を指定する必要はありません。このパラメーターを NULL に設定すると、既定のマッピングオプションが使用されます。 |
| pbag | MAPPING_PROPERTY_BAG* | inout | サービスが結果を格納する MAPPING_PROPERTY_BAG 構造体へのポインターです。入力時には、アプリケーションはサイズのみを設定し、他のメンバーを 0 に設定した構造体を渡します。出力時には、テキスト認識中にサービスが生成した情報が構造体に格納されます。このパラメーターを NULL に設定することはできません。 |
戻り値の型: HRESULT
公式ドキュメント
ELS サービスを呼び出してテキストを認識します。たとえば、Microsoft Language Detection サービスは、入力テキストが記述されている言語を認識しようとします。
戻り値
成功した場合は S_OK を返します。成功しなかった場合、関数はエラー HRESULT 値を返します。
解説(Remarks)
認識するテキストの種類は、アプリケーションが使用するサービスの種類によって異なります。詳細については、Requesting Text Recognition を参照してください。
Warning pszText および pOptions が参照するデータは、pBag で渡されるプロパティバッグ構造体が
MappingFreePropertyBag によって解放されるまで有効なままである必要があります。これは、MappingRecognizeText および MappingDoAction への同期呼び出しと非同期呼び出しの両方が、最初の
MappingRecognizeText の呼び出しに渡されたデータを使用しようとするためです。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// elscore.dll
#include <windows.h>
HRESULT MappingRecognizeText(
MAPPING_SERVICE_INFO* pServiceInfo,
LPCWSTR pszText,
DWORD dwLength,
DWORD dwIndex,
MAPPING_OPTIONS* pOptions, // optional
MAPPING_PROPERTY_BAG* pbag
);[DllImport("elscore.dll", ExactSpelling = true)]
static extern int MappingRecognizeText(
IntPtr pServiceInfo, // MAPPING_SERVICE_INFO*
[MarshalAs(UnmanagedType.LPWStr)] string pszText, // LPCWSTR
uint dwLength, // DWORD
uint dwIndex, // DWORD
IntPtr pOptions, // MAPPING_OPTIONS* optional
IntPtr pbag // MAPPING_PROPERTY_BAG* in/out
);<DllImport("elscore.dll", ExactSpelling:=True)>
Public Shared Function MappingRecognizeText(
pServiceInfo As IntPtr, ' MAPPING_SERVICE_INFO*
<MarshalAs(UnmanagedType.LPWStr)> pszText As String, ' LPCWSTR
dwLength As UInteger, ' DWORD
dwIndex As UInteger, ' DWORD
pOptions As IntPtr, ' MAPPING_OPTIONS* optional
pbag As IntPtr ' MAPPING_PROPERTY_BAG* in/out
) As Integer
End Function' pServiceInfo : MAPPING_SERVICE_INFO*
' pszText : LPCWSTR
' dwLength : DWORD
' dwIndex : DWORD
' pOptions : MAPPING_OPTIONS* optional
' pbag : MAPPING_PROPERTY_BAG* in/out
Declare PtrSafe Function MappingRecognizeText Lib "elscore" ( _
ByVal pServiceInfo As LongPtr, _
ByVal pszText As LongPtr, _
ByVal dwLength As Long, _
ByVal dwIndex As Long, _
ByVal pOptions As LongPtr, _
ByVal pbag As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MappingRecognizeText = ctypes.windll.elscore.MappingRecognizeText
MappingRecognizeText.restype = ctypes.c_int
MappingRecognizeText.argtypes = [
ctypes.c_void_p, # pServiceInfo : MAPPING_SERVICE_INFO*
wintypes.LPCWSTR, # pszText : LPCWSTR
wintypes.DWORD, # dwLength : DWORD
wintypes.DWORD, # dwIndex : DWORD
ctypes.c_void_p, # pOptions : MAPPING_OPTIONS* optional
ctypes.c_void_p, # pbag : MAPPING_PROPERTY_BAG* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('elscore.dll')
MappingRecognizeText = Fiddle::Function.new(
lib['MappingRecognizeText'],
[
Fiddle::TYPE_VOIDP, # pServiceInfo : MAPPING_SERVICE_INFO*
Fiddle::TYPE_VOIDP, # pszText : LPCWSTR
-Fiddle::TYPE_INT, # dwLength : DWORD
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # pOptions : MAPPING_OPTIONS* optional
Fiddle::TYPE_VOIDP, # pbag : MAPPING_PROPERTY_BAG* in/out
],
Fiddle::TYPE_INT)#[link(name = "elscore")]
extern "system" {
fn MappingRecognizeText(
pServiceInfo: *mut MAPPING_SERVICE_INFO, // MAPPING_SERVICE_INFO*
pszText: *const u16, // LPCWSTR
dwLength: u32, // DWORD
dwIndex: u32, // DWORD
pOptions: *mut MAPPING_OPTIONS, // MAPPING_OPTIONS* optional
pbag: *mut MAPPING_PROPERTY_BAG // MAPPING_PROPERTY_BAG* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("elscore.dll")]
public static extern int MappingRecognizeText(IntPtr pServiceInfo, [MarshalAs(UnmanagedType.LPWStr)] string pszText, uint dwLength, uint dwIndex, IntPtr pOptions, IntPtr pbag);
"@
$api = Add-Type -MemberDefinition $sig -Name 'elscore_MappingRecognizeText' -Namespace Win32 -PassThru
# $api::MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)#uselib "elscore.dll"
#func global MappingRecognizeText "MappingRecognizeText" sptr, sptr, sptr, sptr, sptr, sptr
; MappingRecognizeText varptr(pServiceInfo), pszText, dwLength, dwIndex, varptr(pOptions), varptr(pbag) ; 戻り値は stat
; pServiceInfo : MAPPING_SERVICE_INFO* -> "sptr"
; pszText : LPCWSTR -> "sptr"
; dwLength : DWORD -> "sptr"
; dwIndex : DWORD -> "sptr"
; pOptions : MAPPING_OPTIONS* optional -> "sptr"
; pbag : MAPPING_PROPERTY_BAG* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "elscore.dll" #cfunc global MappingRecognizeText "MappingRecognizeText" var, wstr, int, int, var, var ; res = MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag) ; pServiceInfo : MAPPING_SERVICE_INFO* -> "var" ; pszText : LPCWSTR -> "wstr" ; dwLength : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pOptions : MAPPING_OPTIONS* optional -> "var" ; pbag : MAPPING_PROPERTY_BAG* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "elscore.dll" #cfunc global MappingRecognizeText "MappingRecognizeText" sptr, wstr, int, int, sptr, sptr ; res = MappingRecognizeText(varptr(pServiceInfo), pszText, dwLength, dwIndex, varptr(pOptions), varptr(pbag)) ; pServiceInfo : MAPPING_SERVICE_INFO* -> "sptr" ; pszText : LPCWSTR -> "wstr" ; dwLength : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pOptions : MAPPING_OPTIONS* optional -> "sptr" ; pbag : MAPPING_PROPERTY_BAG* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MappingRecognizeText(MAPPING_SERVICE_INFO* pServiceInfo, LPCWSTR pszText, DWORD dwLength, DWORD dwIndex, MAPPING_OPTIONS* pOptions, MAPPING_PROPERTY_BAG* pbag) #uselib "elscore.dll" #cfunc global MappingRecognizeText "MappingRecognizeText" var, wstr, int, int, var, var ; res = MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag) ; pServiceInfo : MAPPING_SERVICE_INFO* -> "var" ; pszText : LPCWSTR -> "wstr" ; dwLength : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pOptions : MAPPING_OPTIONS* optional -> "var" ; pbag : MAPPING_PROPERTY_BAG* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MappingRecognizeText(MAPPING_SERVICE_INFO* pServiceInfo, LPCWSTR pszText, DWORD dwLength, DWORD dwIndex, MAPPING_OPTIONS* pOptions, MAPPING_PROPERTY_BAG* pbag) #uselib "elscore.dll" #cfunc global MappingRecognizeText "MappingRecognizeText" intptr, wstr, int, int, intptr, intptr ; res = MappingRecognizeText(varptr(pServiceInfo), pszText, dwLength, dwIndex, varptr(pOptions), varptr(pbag)) ; pServiceInfo : MAPPING_SERVICE_INFO* -> "intptr" ; pszText : LPCWSTR -> "wstr" ; dwLength : DWORD -> "int" ; dwIndex : DWORD -> "int" ; pOptions : MAPPING_OPTIONS* optional -> "intptr" ; pbag : MAPPING_PROPERTY_BAG* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
elscore = windows.NewLazySystemDLL("elscore.dll")
procMappingRecognizeText = elscore.NewProc("MappingRecognizeText")
)
// pServiceInfo (MAPPING_SERVICE_INFO*), pszText (LPCWSTR), dwLength (DWORD), dwIndex (DWORD), pOptions (MAPPING_OPTIONS* optional), pbag (MAPPING_PROPERTY_BAG* in/out)
r1, _, err := procMappingRecognizeText.Call(
uintptr(pServiceInfo),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszText))),
uintptr(dwLength),
uintptr(dwIndex),
uintptr(pOptions),
uintptr(pbag),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MappingRecognizeText(
pServiceInfo: Pointer; // MAPPING_SERVICE_INFO*
pszText: PWideChar; // LPCWSTR
dwLength: DWORD; // DWORD
dwIndex: DWORD; // DWORD
pOptions: Pointer; // MAPPING_OPTIONS* optional
pbag: Pointer // MAPPING_PROPERTY_BAG* in/out
): Integer; stdcall;
external 'elscore.dll' name 'MappingRecognizeText';result := DllCall("elscore\MappingRecognizeText"
, "Ptr", pServiceInfo ; MAPPING_SERVICE_INFO*
, "WStr", pszText ; LPCWSTR
, "UInt", dwLength ; DWORD
, "UInt", dwIndex ; DWORD
, "Ptr", pOptions ; MAPPING_OPTIONS* optional
, "Ptr", pbag ; MAPPING_PROPERTY_BAG* in/out
, "Int") ; return: HRESULT●MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag) = DLL("elscore.dll", "int MappingRecognizeText(void*, char*, dword, dword, void*, void*)")
# 呼び出し: MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)
# pServiceInfo : MAPPING_SERVICE_INFO* -> "void*"
# pszText : LPCWSTR -> "char*"
# dwLength : DWORD -> "dword"
# dwIndex : DWORD -> "dword"
# pOptions : MAPPING_OPTIONS* optional -> "void*"
# pbag : MAPPING_PROPERTY_BAG* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "elscore" fn MappingRecognizeText(
pServiceInfo: [*c]MAPPING_SERVICE_INFO, // MAPPING_SERVICE_INFO*
pszText: [*c]const u16, // LPCWSTR
dwLength: u32, // DWORD
dwIndex: u32, // DWORD
pOptions: [*c]MAPPING_OPTIONS, // MAPPING_OPTIONS* optional
pbag: [*c]MAPPING_PROPERTY_BAG // MAPPING_PROPERTY_BAG* in/out
) callconv(std.os.windows.WINAPI) i32;proc MappingRecognizeText(
pServiceInfo: ptr MAPPING_SERVICE_INFO, # MAPPING_SERVICE_INFO*
pszText: WideCString, # LPCWSTR
dwLength: uint32, # DWORD
dwIndex: uint32, # DWORD
pOptions: ptr MAPPING_OPTIONS, # MAPPING_OPTIONS* optional
pbag: ptr MAPPING_PROPERTY_BAG # MAPPING_PROPERTY_BAG* in/out
): int32 {.importc: "MappingRecognizeText", stdcall, dynlib: "elscore.dll".}pragma(lib, "elscore");
extern(Windows)
int MappingRecognizeText(
MAPPING_SERVICE_INFO* pServiceInfo, // MAPPING_SERVICE_INFO*
const(wchar)* pszText, // LPCWSTR
uint dwLength, // DWORD
uint dwIndex, // DWORD
MAPPING_OPTIONS* pOptions, // MAPPING_OPTIONS* optional
MAPPING_PROPERTY_BAG* pbag // MAPPING_PROPERTY_BAG* in/out
);ccall((:MappingRecognizeText, "elscore.dll"), stdcall, Int32,
(Ptr{MAPPING_SERVICE_INFO}, Cwstring, UInt32, UInt32, Ptr{MAPPING_OPTIONS}, Ptr{MAPPING_PROPERTY_BAG}),
pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)
# pServiceInfo : MAPPING_SERVICE_INFO* -> Ptr{MAPPING_SERVICE_INFO}
# pszText : LPCWSTR -> Cwstring
# dwLength : DWORD -> UInt32
# dwIndex : DWORD -> UInt32
# pOptions : MAPPING_OPTIONS* optional -> Ptr{MAPPING_OPTIONS}
# pbag : MAPPING_PROPERTY_BAG* in/out -> Ptr{MAPPING_PROPERTY_BAG}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MappingRecognizeText(
void* pServiceInfo,
const uint16_t* pszText,
uint32_t dwLength,
uint32_t dwIndex,
void* pOptions,
void* pbag);
]]
local elscore = ffi.load("elscore")
-- elscore.MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)
-- pServiceInfo : MAPPING_SERVICE_INFO*
-- pszText : LPCWSTR
-- dwLength : DWORD
-- dwIndex : DWORD
-- pOptions : MAPPING_OPTIONS* optional
-- pbag : MAPPING_PROPERTY_BAG* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('elscore.dll');
const MappingRecognizeText = lib.func('__stdcall', 'MappingRecognizeText', 'int32_t', ['void *', 'str16', 'uint32_t', 'uint32_t', 'void *', 'void *']);
// MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)
// pServiceInfo : MAPPING_SERVICE_INFO* -> 'void *'
// pszText : LPCWSTR -> 'str16'
// dwLength : DWORD -> 'uint32_t'
// dwIndex : DWORD -> 'uint32_t'
// pOptions : MAPPING_OPTIONS* optional -> 'void *'
// pbag : MAPPING_PROPERTY_BAG* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("elscore.dll", {
MappingRecognizeText: { parameters: ["pointer", "buffer", "u32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag)
// pServiceInfo : MAPPING_SERVICE_INFO* -> "pointer"
// pszText : LPCWSTR -> "buffer"
// dwLength : DWORD -> "u32"
// dwIndex : DWORD -> "u32"
// pOptions : MAPPING_OPTIONS* optional -> "pointer"
// pbag : MAPPING_PROPERTY_BAG* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MappingRecognizeText(
void* pServiceInfo,
const uint16_t* pszText,
uint32_t dwLength,
uint32_t dwIndex,
void* pOptions,
void* pbag);
C, "elscore.dll");
// $ffi->MappingRecognizeText(pServiceInfo, pszText, dwLength, dwIndex, pOptions, pbag);
// pServiceInfo : MAPPING_SERVICE_INFO*
// pszText : LPCWSTR
// dwLength : DWORD
// dwIndex : DWORD
// pOptions : MAPPING_OPTIONS* optional
// pbag : MAPPING_PROPERTY_BAG* 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 Elscore extends StdCallLibrary {
Elscore INSTANCE = Native.load("elscore", Elscore.class);
int MappingRecognizeText(
Pointer pServiceInfo, // MAPPING_SERVICE_INFO*
WString pszText, // LPCWSTR
int dwLength, // DWORD
int dwIndex, // DWORD
Pointer pOptions, // MAPPING_OPTIONS* optional
Pointer pbag // MAPPING_PROPERTY_BAG* in/out
);
}@[Link("elscore")]
lib Libelscore
fun MappingRecognizeText = MappingRecognizeText(
pServiceInfo : MAPPING_SERVICE_INFO*, # MAPPING_SERVICE_INFO*
pszText : UInt16*, # LPCWSTR
dwLength : UInt32, # DWORD
dwIndex : UInt32, # DWORD
pOptions : MAPPING_OPTIONS*, # MAPPING_OPTIONS* optional
pbag : MAPPING_PROPERTY_BAG* # MAPPING_PROPERTY_BAG* 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 MappingRecognizeTextNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef MappingRecognizeTextDart = int Function(Pointer<Void>, Pointer<Utf16>, int, int, Pointer<Void>, Pointer<Void>);
final MappingRecognizeText = DynamicLibrary.open('elscore.dll')
.lookupFunction<MappingRecognizeTextNative, MappingRecognizeTextDart>('MappingRecognizeText');
// pServiceInfo : MAPPING_SERVICE_INFO* -> Pointer<Void>
// pszText : LPCWSTR -> Pointer<Utf16>
// dwLength : DWORD -> Uint32
// dwIndex : DWORD -> Uint32
// pOptions : MAPPING_OPTIONS* optional -> Pointer<Void>
// pbag : MAPPING_PROPERTY_BAG* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MappingRecognizeText(
pServiceInfo: Pointer; // MAPPING_SERVICE_INFO*
pszText: PWideChar; // LPCWSTR
dwLength: DWORD; // DWORD
dwIndex: DWORD; // DWORD
pOptions: Pointer; // MAPPING_OPTIONS* optional
pbag: Pointer // MAPPING_PROPERTY_BAG* in/out
): Integer; stdcall;
external 'elscore.dll' name 'MappingRecognizeText';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MappingRecognizeText"
c_MappingRecognizeText :: Ptr () -> CWString -> Word32 -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- pServiceInfo : MAPPING_SERVICE_INFO* -> Ptr ()
-- pszText : LPCWSTR -> CWString
-- dwLength : DWORD -> Word32
-- dwIndex : DWORD -> Word32
-- pOptions : MAPPING_OPTIONS* optional -> Ptr ()
-- pbag : MAPPING_PROPERTY_BAG* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mappingrecognizetext =
foreign "MappingRecognizeText"
((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pServiceInfo : MAPPING_SERVICE_INFO* -> (ptr void) *)
(* pszText : LPCWSTR -> (ptr uint16_t) *)
(* dwLength : DWORD -> uint32_t *)
(* dwIndex : DWORD -> uint32_t *)
(* pOptions : MAPPING_OPTIONS* optional -> (ptr void) *)
(* pbag : MAPPING_PROPERTY_BAG* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library elscore (t "elscore.dll"))
(cffi:use-foreign-library elscore)
(cffi:defcfun ("MappingRecognizeText" mapping-recognize-text :convention :stdcall) :int32
(p-service-info :pointer) ; MAPPING_SERVICE_INFO*
(psz-text (:string :encoding :utf-16le)) ; LPCWSTR
(dw-length :uint32) ; DWORD
(dw-index :uint32) ; DWORD
(p-options :pointer) ; MAPPING_OPTIONS* optional
(pbag :pointer)) ; MAPPING_PROPERTY_BAG* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MappingRecognizeText = Win32::API::More->new('elscore',
'int MappingRecognizeText(LPVOID pServiceInfo, LPCWSTR pszText, DWORD dwLength, DWORD dwIndex, LPVOID pOptions, LPVOID pbag)');
# my $ret = $MappingRecognizeText->Call($pServiceInfo, $pszText, $dwLength, $dwIndex, $pOptions, $pbag);
# pServiceInfo : MAPPING_SERVICE_INFO* -> LPVOID
# pszText : LPCWSTR -> LPCWSTR
# dwLength : DWORD -> DWORD
# dwIndex : DWORD -> DWORD
# pOptions : MAPPING_OPTIONS* optional -> LPVOID
# pbag : MAPPING_PROPERTY_BAG* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。