Win32 API 日本語リファレンス
ホームUI.TabletPC › GetBestResultString

GetBestResultString

関数
認識結果の最有力文字列を取得する。
DLLinkobjcore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT GetBestResultString(
    HRECOCONTEXT hrc,
    DWORD* pcSize,
    LPWSTR pwcBestResult   // optional
);

パラメーター

名前方向説明
hrcHRECOCONTEXTin結果を取得する認識コンテキストのハンドル(HRECOCONTEXT)。
pcSizeDWORD*inout文字数を入出力するポインタ。入力でバッファ容量、出力で必要または実際の文字数。
pwcBestResultLPWSTRoutoptional最有力の認識結果文字列を受け取るバッファ。NULLで必要サイズのみ取得。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetBestResultString(
    HRECOCONTEXT hrc,
    DWORD* pcSize,
    LPWSTR pwcBestResult   // optional
);
[DllImport("inkobjcore.dll", ExactSpelling = true)]
static extern int GetBestResultString(
    IntPtr hrc,   // HRECOCONTEXT
    ref uint pcSize,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pwcBestResult   // LPWSTR optional, out
);
<DllImport("inkobjcore.dll", ExactSpelling:=True)>
Public Shared Function GetBestResultString(
    hrc As IntPtr,   ' HRECOCONTEXT
    ByRef pcSize As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pwcBestResult As System.Text.StringBuilder   ' LPWSTR optional, out
) As Integer
End Function
' hrc : HRECOCONTEXT
' pcSize : DWORD* in/out
' pwcBestResult : LPWSTR optional, out
Declare PtrSafe Function GetBestResultString Lib "inkobjcore" ( _
    ByVal hrc As LongPtr, _
    ByRef pcSize As Long, _
    ByVal pwcBestResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetBestResultString = ctypes.windll.inkobjcore.GetBestResultString
GetBestResultString.restype = ctypes.c_int
GetBestResultString.argtypes = [
    wintypes.HANDLE,  # hrc : HRECOCONTEXT
    ctypes.POINTER(wintypes.DWORD),  # pcSize : DWORD* in/out
    wintypes.LPWSTR,  # pwcBestResult : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	inkobjcore = windows.NewLazySystemDLL("inkobjcore.dll")
	procGetBestResultString = inkobjcore.NewProc("GetBestResultString")
)

// hrc (HRECOCONTEXT), pcSize (DWORD* in/out), pwcBestResult (LPWSTR optional, out)
r1, _, err := procGetBestResultString.Call(
	uintptr(hrc),
	uintptr(pcSize),
	uintptr(pwcBestResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetBestResultString(
  hrc: THandle;   // HRECOCONTEXT
  pcSize: Pointer;   // DWORD* in/out
  pwcBestResult: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'inkobjcore.dll' name 'GetBestResultString';
result := DllCall("inkobjcore\GetBestResultString"
    , "Ptr", hrc   ; HRECOCONTEXT
    , "Ptr", pcSize   ; DWORD* in/out
    , "Ptr", pwcBestResult   ; LPWSTR optional, out
    , "Int")   ; return: HRESULT
●GetBestResultString(hrc, pcSize, pwcBestResult) = DLL("inkobjcore.dll", "int GetBestResultString(void*, void*, char*)")
# 呼び出し: GetBestResultString(hrc, pcSize, pwcBestResult)
# hrc : HRECOCONTEXT -> "void*"
# pcSize : DWORD* in/out -> "void*"
# pwcBestResult : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef GetBestResultStringNative = Int32 Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
typedef GetBestResultStringDart = int Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
final GetBestResultString = DynamicLibrary.open('inkobjcore.dll')
    .lookupFunction<GetBestResultStringNative, GetBestResultStringDart>('GetBestResultString');
// hrc : HRECOCONTEXT -> Pointer<Void>
// pcSize : DWORD* in/out -> Pointer<Uint32>
// pwcBestResult : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetBestResultString(
  hrc: THandle;   // HRECOCONTEXT
  pcSize: Pointer;   // DWORD* in/out
  pwcBestResult: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'inkobjcore.dll' name 'GetBestResultString';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetBestResultString"
  c_GetBestResultString :: Ptr () -> Ptr Word32 -> CWString -> IO Int32
-- hrc : HRECOCONTEXT -> Ptr ()
-- pcSize : DWORD* in/out -> Ptr Word32
-- pwcBestResult : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getbestresultstring =
  foreign "GetBestResultString"
    ((ptr void) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hrc : HRECOCONTEXT -> (ptr void) *)
(* pcSize : DWORD* in/out -> (ptr uint32_t) *)
(* pwcBestResult : LPWSTR optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library inkobjcore (t "inkobjcore.dll"))
(cffi:use-foreign-library inkobjcore)

(cffi:defcfun ("GetBestResultString" get-best-result-string :convention :stdcall) :int32
  (hrc :pointer)   ; HRECOCONTEXT
  (pc-size :pointer)   ; DWORD* in/out
  (pwc-best-result :pointer))   ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetBestResultString = Win32::API::More->new('inkobjcore',
    'int GetBestResultString(HANDLE hrc, LPVOID pcSize, LPWSTR pwcBestResult)');
# my $ret = $GetBestResultString->Call($hrc, $pcSize, $pwcBestResult);
# hrc : HRECOCONTEXT -> HANDLE
# pcSize : DWORD* in/out -> LPVOID
# pwcBestResult : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。