Win32 API 日本語リファレンス
ホームGlobalization › MappingDoAction

MappingDoAction

関数
認識結果の指定範囲に対しELSアクションを実行する。
DLLelscore.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT MappingDoAction(
    MAPPING_PROPERTY_BAG* pBag,
    DWORD dwRangeIndex,
    LPCWSTR pszActionId
);

パラメーター

名前方向説明
pBagMAPPING_PROPERTY_BAG*inoutMAPPING_PROPERTY_BAG 構造体へのポインター。これには、直前に呼び出した MappingRecognizeText の結果が格納されています。このパラメーターに NULL を設定することはできません。
dwRangeIndexDWORDin認識されたテキスト範囲について、テキスト認識結果内の開始インデックス。この値は 0 から範囲数までの間である必要があります。
pszActionIdLPCWSTRin実行するアクションの識別子へのポインター。このパラメーターに NULL を設定することはできません。

戻り値の型: HRESULT

公式ドキュメント

ELS サービスに対し、テキスト認識が行われた後にアクションを実行させます。たとえば、電話ダイヤラー サービスはまず電話番号を認識し、その後で番号にダイヤルするという「アクション」を実行できます。

戻り値

成功した場合は S_OK を返します。成功しなかった場合、この関数はエラーを示す HRESULT 値を返します。

解説(Remarks)

アプリケーションは、MappingDoAction の呼び出しの前に MappingRecognizeText を呼び出す必要があります。

警告 MappingRecognizeText に渡される 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)

各言語での呼び出し定義

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

HRESULT MappingDoAction(
    MAPPING_PROPERTY_BAG* pBag,
    DWORD dwRangeIndex,
    LPCWSTR pszActionId
);
[DllImport("elscore.dll", ExactSpelling = true)]
static extern int MappingDoAction(
    IntPtr pBag,   // MAPPING_PROPERTY_BAG* in/out
    uint dwRangeIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszActionId   // LPCWSTR
);
<DllImport("elscore.dll", ExactSpelling:=True)>
Public Shared Function MappingDoAction(
    pBag As IntPtr,   ' MAPPING_PROPERTY_BAG* in/out
    dwRangeIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszActionId As String   ' LPCWSTR
) As Integer
End Function
' pBag : MAPPING_PROPERTY_BAG* in/out
' dwRangeIndex : DWORD
' pszActionId : LPCWSTR
Declare PtrSafe Function MappingDoAction Lib "elscore" ( _
    ByVal pBag As LongPtr, _
    ByVal dwRangeIndex As Long, _
    ByVal pszActionId As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MappingDoAction = ctypes.windll.elscore.MappingDoAction
MappingDoAction.restype = ctypes.c_int
MappingDoAction.argtypes = [
    ctypes.c_void_p,  # pBag : MAPPING_PROPERTY_BAG* in/out
    wintypes.DWORD,  # dwRangeIndex : DWORD
    wintypes.LPCWSTR,  # pszActionId : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('elscore.dll')
MappingDoAction = Fiddle::Function.new(
  lib['MappingDoAction'],
  [
    Fiddle::TYPE_VOIDP,  # pBag : MAPPING_PROPERTY_BAG* in/out
    -Fiddle::TYPE_INT,  # dwRangeIndex : DWORD
    Fiddle::TYPE_VOIDP,  # pszActionId : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "elscore")]
extern "system" {
    fn MappingDoAction(
        pBag: *mut MAPPING_PROPERTY_BAG,  // MAPPING_PROPERTY_BAG* in/out
        dwRangeIndex: u32,  // DWORD
        pszActionId: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("elscore.dll")]
public static extern int MappingDoAction(IntPtr pBag, uint dwRangeIndex, [MarshalAs(UnmanagedType.LPWStr)] string pszActionId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'elscore_MappingDoAction' -Namespace Win32 -PassThru
# $api::MappingDoAction(pBag, dwRangeIndex, pszActionId)
#uselib "elscore.dll"
#func global MappingDoAction "MappingDoAction" sptr, sptr, sptr
; MappingDoAction varptr(pBag), dwRangeIndex, pszActionId   ; 戻り値は stat
; pBag : MAPPING_PROPERTY_BAG* in/out -> "sptr"
; dwRangeIndex : DWORD -> "sptr"
; pszActionId : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "elscore.dll"
#cfunc global MappingDoAction "MappingDoAction" var, int, wstr
; res = MappingDoAction(pBag, dwRangeIndex, pszActionId)
; pBag : MAPPING_PROPERTY_BAG* in/out -> "var"
; dwRangeIndex : DWORD -> "int"
; pszActionId : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT MappingDoAction(MAPPING_PROPERTY_BAG* pBag, DWORD dwRangeIndex, LPCWSTR pszActionId)
#uselib "elscore.dll"
#cfunc global MappingDoAction "MappingDoAction" var, int, wstr
; res = MappingDoAction(pBag, dwRangeIndex, pszActionId)
; pBag : MAPPING_PROPERTY_BAG* in/out -> "var"
; dwRangeIndex : DWORD -> "int"
; pszActionId : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	elscore = windows.NewLazySystemDLL("elscore.dll")
	procMappingDoAction = elscore.NewProc("MappingDoAction")
)

// pBag (MAPPING_PROPERTY_BAG* in/out), dwRangeIndex (DWORD), pszActionId (LPCWSTR)
r1, _, err := procMappingDoAction.Call(
	uintptr(pBag),
	uintptr(dwRangeIndex),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszActionId))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MappingDoAction(
  pBag: Pointer;   // MAPPING_PROPERTY_BAG* in/out
  dwRangeIndex: DWORD;   // DWORD
  pszActionId: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'elscore.dll' name 'MappingDoAction';
result := DllCall("elscore\MappingDoAction"
    , "Ptr", pBag   ; MAPPING_PROPERTY_BAG* in/out
    , "UInt", dwRangeIndex   ; DWORD
    , "WStr", pszActionId   ; LPCWSTR
    , "Int")   ; return: HRESULT
●MappingDoAction(pBag, dwRangeIndex, pszActionId) = DLL("elscore.dll", "int MappingDoAction(void*, dword, char*)")
# 呼び出し: MappingDoAction(pBag, dwRangeIndex, pszActionId)
# pBag : MAPPING_PROPERTY_BAG* in/out -> "void*"
# dwRangeIndex : DWORD -> "dword"
# pszActionId : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef MappingDoActionNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>);
typedef MappingDoActionDart = int Function(Pointer<Void>, int, Pointer<Utf16>);
final MappingDoAction = DynamicLibrary.open('elscore.dll')
    .lookupFunction<MappingDoActionNative, MappingDoActionDart>('MappingDoAction');
// pBag : MAPPING_PROPERTY_BAG* in/out -> Pointer<Void>
// dwRangeIndex : DWORD -> Uint32
// pszActionId : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MappingDoAction(
  pBag: Pointer;   // MAPPING_PROPERTY_BAG* in/out
  dwRangeIndex: DWORD;   // DWORD
  pszActionId: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'elscore.dll' name 'MappingDoAction';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MappingDoAction"
  c_MappingDoAction :: Ptr () -> Word32 -> CWString -> IO Int32
-- pBag : MAPPING_PROPERTY_BAG* in/out -> Ptr ()
-- dwRangeIndex : DWORD -> Word32
-- pszActionId : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mappingdoaction =
  foreign "MappingDoAction"
    ((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> returning int32_t)
(* pBag : MAPPING_PROPERTY_BAG* in/out -> (ptr void) *)
(* dwRangeIndex : DWORD -> uint32_t *)
(* pszActionId : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library elscore (t "elscore.dll"))
(cffi:use-foreign-library elscore)

(cffi:defcfun ("MappingDoAction" mapping-do-action :convention :stdcall) :int32
  (p-bag :pointer)   ; MAPPING_PROPERTY_BAG* in/out
  (dw-range-index :uint32)   ; DWORD
  (psz-action-id (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MappingDoAction = Win32::API::More->new('elscore',
    'int MappingDoAction(LPVOID pBag, DWORD dwRangeIndex, LPCWSTR pszActionId)');
# my $ret = $MappingDoAction->Call($pBag, $dwRangeIndex, $pszActionId);
# pBag : MAPPING_PROPERTY_BAG* in/out -> LPVOID
# dwRangeIndex : DWORD -> DWORD
# pszActionId : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型