ホーム › 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 |
| pszText | LPCWSTR | in |
| dwLength | DWORD | in |
| dwIndex | DWORD | in |
| pOptions | MAPPING_OPTIONS* | inoptional |
| pbag | MAPPING_PROPERTY_BAG* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// 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)。