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

SetContextPropertyValue

関数
認識コンテキストのプロパティ値を設定する。
DLLinkobjcore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT SetContextPropertyValue(
    HRECOCONTEXT hrc,
    GUID* pGuid,
    DWORD cbSize,
    BYTE* pProperty
);

パラメーター

名前方向説明
hrcHRECOCONTEXTin対象の認識コンテキストのハンドル(HRECOCONTEXT)。
pGuidGUID*inout設定するプロパティを識別するGUIDへのポインタ。
cbSizeDWORDin設定するプロパティ値のバイト単位サイズ。
pPropertyBYTE*inout設定するプロパティ値を保持するバイトバッファへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SetContextPropertyValue(
    HRECOCONTEXT hrc,
    GUID* pGuid,
    DWORD cbSize,
    BYTE* pProperty
);
[DllImport("inkobjcore.dll", ExactSpelling = true)]
static extern int SetContextPropertyValue(
    IntPtr hrc,   // HRECOCONTEXT
    ref Guid pGuid,   // GUID* in/out
    uint cbSize,   // DWORD
    IntPtr pProperty   // BYTE* in/out
);
<DllImport("inkobjcore.dll", ExactSpelling:=True)>
Public Shared Function SetContextPropertyValue(
    hrc As IntPtr,   ' HRECOCONTEXT
    ByRef pGuid As Guid,   ' GUID* in/out
    cbSize As UInteger,   ' DWORD
    pProperty As IntPtr   ' BYTE* in/out
) As Integer
End Function
' hrc : HRECOCONTEXT
' pGuid : GUID* in/out
' cbSize : DWORD
' pProperty : BYTE* in/out
Declare PtrSafe Function SetContextPropertyValue Lib "inkobjcore" ( _
    ByVal hrc As LongPtr, _
    ByVal pGuid As LongPtr, _
    ByVal cbSize As Long, _
    ByVal pProperty As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetContextPropertyValue = ctypes.windll.inkobjcore.SetContextPropertyValue
SetContextPropertyValue.restype = ctypes.c_int
SetContextPropertyValue.argtypes = [
    wintypes.HANDLE,  # hrc : HRECOCONTEXT
    ctypes.c_void_p,  # pGuid : GUID* in/out
    wintypes.DWORD,  # cbSize : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pProperty : BYTE* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	inkobjcore = windows.NewLazySystemDLL("inkobjcore.dll")
	procSetContextPropertyValue = inkobjcore.NewProc("SetContextPropertyValue")
)

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

extern "inkobjcore" fn SetContextPropertyValue(
    hrc: ?*anyopaque, // HRECOCONTEXT
    pGuid: [*c]GUID, // GUID* in/out
    cbSize: u32, // DWORD
    pProperty: [*c]u8 // BYTE* in/out
) callconv(std.os.windows.WINAPI) i32;
proc SetContextPropertyValue(
    hrc: pointer,  # HRECOCONTEXT
    pGuid: ptr GUID,  # GUID* in/out
    cbSize: uint32,  # DWORD
    pProperty: ptr uint8  # BYTE* in/out
): int32 {.importc: "SetContextPropertyValue", stdcall, dynlib: "inkobjcore.dll".}
pragma(lib, "inkobjcore");
extern(Windows)
int SetContextPropertyValue(
    void* hrc,   // HRECOCONTEXT
    GUID* pGuid,   // GUID* in/out
    uint cbSize,   // DWORD
    ubyte* pProperty   // BYTE* in/out
);
ccall((:SetContextPropertyValue, "inkobjcore.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{GUID}, UInt32, Ptr{UInt8}),
      hrc, pGuid, cbSize, pProperty)
# hrc : HRECOCONTEXT -> Ptr{Cvoid}
# pGuid : GUID* in/out -> Ptr{GUID}
# cbSize : DWORD -> UInt32
# pProperty : BYTE* in/out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetContextPropertyValue(
    void* hrc,
    void* pGuid,
    uint32_t cbSize,
    uint8_t* pProperty);
]]
local inkobjcore = ffi.load("inkobjcore")
-- inkobjcore.SetContextPropertyValue(hrc, pGuid, cbSize, pProperty)
-- hrc : HRECOCONTEXT
-- pGuid : GUID* in/out
-- cbSize : DWORD
-- pProperty : BYTE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('inkobjcore.dll');
const SetContextPropertyValue = lib.func('__stdcall', 'SetContextPropertyValue', 'int32_t', ['void *', 'void *', 'uint32_t', 'uint8_t *']);
// SetContextPropertyValue(hrc, pGuid, cbSize, pProperty)
// hrc : HRECOCONTEXT -> 'void *'
// pGuid : GUID* in/out -> 'void *'
// cbSize : DWORD -> 'uint32_t'
// pProperty : BYTE* in/out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("inkobjcore.dll", {
  SetContextPropertyValue: { parameters: ["pointer", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetContextPropertyValue(hrc, pGuid, cbSize, pProperty)
// hrc : HRECOCONTEXT -> "pointer"
// pGuid : GUID* in/out -> "pointer"
// cbSize : DWORD -> "u32"
// pProperty : BYTE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetContextPropertyValue(
    void* hrc,
    void* pGuid,
    uint32_t cbSize,
    uint8_t* pProperty);
C, "inkobjcore.dll");
// $ffi->SetContextPropertyValue(hrc, pGuid, cbSize, pProperty);
// hrc : HRECOCONTEXT
// pGuid : GUID* in/out
// cbSize : DWORD
// pProperty : BYTE* 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 Inkobjcore extends StdCallLibrary {
    Inkobjcore INSTANCE = Native.load("inkobjcore", Inkobjcore.class);
    int SetContextPropertyValue(
        Pointer hrc,   // HRECOCONTEXT
        Pointer pGuid,   // GUID* in/out
        int cbSize,   // DWORD
        byte[] pProperty   // BYTE* in/out
    );
}
@[Link("inkobjcore")]
lib Libinkobjcore
  fun SetContextPropertyValue = SetContextPropertyValue(
    hrc : Void*,   # HRECOCONTEXT
    pGuid : GUID*,   # GUID* in/out
    cbSize : UInt32,   # DWORD
    pProperty : UInt8*   # BYTE* 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 SetContextPropertyValueNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Uint8>);
typedef SetContextPropertyValueDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Uint8>);
final SetContextPropertyValue = DynamicLibrary.open('inkobjcore.dll')
    .lookupFunction<SetContextPropertyValueNative, SetContextPropertyValueDart>('SetContextPropertyValue');
// hrc : HRECOCONTEXT -> Pointer<Void>
// pGuid : GUID* in/out -> Pointer<Void>
// cbSize : DWORD -> Uint32
// pProperty : BYTE* in/out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetContextPropertyValue(
  hrc: THandle;   // HRECOCONTEXT
  pGuid: PGUID;   // GUID* in/out
  cbSize: DWORD;   // DWORD
  pProperty: Pointer   // BYTE* in/out
): Integer; stdcall;
  external 'inkobjcore.dll' name 'SetContextPropertyValue';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetContextPropertyValue"
  c_SetContextPropertyValue :: Ptr () -> Ptr () -> Word32 -> Ptr Word8 -> IO Int32
-- hrc : HRECOCONTEXT -> Ptr ()
-- pGuid : GUID* in/out -> Ptr ()
-- cbSize : DWORD -> Word32
-- pProperty : BYTE* in/out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setcontextpropertyvalue =
  foreign "SetContextPropertyValue"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint8_t) @-> returning int32_t)
(* hrc : HRECOCONTEXT -> (ptr void) *)
(* pGuid : GUID* in/out -> (ptr void) *)
(* cbSize : DWORD -> uint32_t *)
(* pProperty : BYTE* in/out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library inkobjcore (t "inkobjcore.dll"))
(cffi:use-foreign-library inkobjcore)

(cffi:defcfun ("SetContextPropertyValue" set-context-property-value :convention :stdcall) :int32
  (hrc :pointer)   ; HRECOCONTEXT
  (p-guid :pointer)   ; GUID* in/out
  (cb-size :uint32)   ; DWORD
  (p-property :pointer))   ; BYTE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetContextPropertyValue = Win32::API::More->new('inkobjcore',
    'int SetContextPropertyValue(HANDLE hrc, LPVOID pGuid, DWORD cbSize, LPVOID pProperty)');
# my $ret = $SetContextPropertyValue->Call($hrc, $pGuid, $cbSize, $pProperty);
# hrc : HRECOCONTEXT -> HANDLE
# pGuid : GUID* in/out -> LPVOID
# cbSize : DWORD -> DWORD
# pProperty : BYTE* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。