ホーム › UI.InteractionContext › SetInteractionConfigurationInteractionContext
SetInteractionConfigurationInteractionContext
関数インタラクションコンテキストの構成設定を行う。
シグネチャ
// NInput.dll
#include <windows.h>
HRESULT SetInteractionConfigurationInteractionContext(
HINTERACTIONCONTEXT interactionContext,
DWORD configurationCount,
const INTERACTION_CONTEXT_CONFIGURATION* configuration
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| interactionContext | HINTERACTIONCONTEXT | in | 対象インタラクションコンテキストのハンドルを指定する。 |
| configurationCount | DWORD | in | configuration配列の要素数を指定する。 |
| configuration | INTERACTION_CONTEXT_CONFIGURATION* | in | 有効にするインタラクション種別と設定を表すINTERACTION_CONTEXT_CONFIGURATION配列へのポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// NInput.dll
#include <windows.h>
HRESULT SetInteractionConfigurationInteractionContext(
HINTERACTIONCONTEXT interactionContext,
DWORD configurationCount,
const INTERACTION_CONTEXT_CONFIGURATION* configuration
);[DllImport("NInput.dll", ExactSpelling = true)]
static extern int SetInteractionConfigurationInteractionContext(
IntPtr interactionContext, // HINTERACTIONCONTEXT
uint configurationCount, // DWORD
IntPtr configuration // INTERACTION_CONTEXT_CONFIGURATION*
);<DllImport("NInput.dll", ExactSpelling:=True)>
Public Shared Function SetInteractionConfigurationInteractionContext(
interactionContext As IntPtr, ' HINTERACTIONCONTEXT
configurationCount As UInteger, ' DWORD
configuration As IntPtr ' INTERACTION_CONTEXT_CONFIGURATION*
) As Integer
End Function' interactionContext : HINTERACTIONCONTEXT
' configurationCount : DWORD
' configuration : INTERACTION_CONTEXT_CONFIGURATION*
Declare PtrSafe Function SetInteractionConfigurationInteractionContext Lib "ninput" ( _
ByVal interactionContext As LongPtr, _
ByVal configurationCount As Long, _
ByVal configuration As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetInteractionConfigurationInteractionContext = ctypes.windll.ninput.SetInteractionConfigurationInteractionContext
SetInteractionConfigurationInteractionContext.restype = ctypes.c_int
SetInteractionConfigurationInteractionContext.argtypes = [
wintypes.HANDLE, # interactionContext : HINTERACTIONCONTEXT
wintypes.DWORD, # configurationCount : DWORD
ctypes.c_void_p, # configuration : INTERACTION_CONTEXT_CONFIGURATION*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NInput.dll')
SetInteractionConfigurationInteractionContext = Fiddle::Function.new(
lib['SetInteractionConfigurationInteractionContext'],
[
Fiddle::TYPE_VOIDP, # interactionContext : HINTERACTIONCONTEXT
-Fiddle::TYPE_INT, # configurationCount : DWORD
Fiddle::TYPE_VOIDP, # configuration : INTERACTION_CONTEXT_CONFIGURATION*
],
Fiddle::TYPE_INT)#[link(name = "ninput")]
extern "system" {
fn SetInteractionConfigurationInteractionContext(
interactionContext: *mut core::ffi::c_void, // HINTERACTIONCONTEXT
configurationCount: u32, // DWORD
configuration: *const INTERACTION_CONTEXT_CONFIGURATION // INTERACTION_CONTEXT_CONFIGURATION*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NInput.dll")]
public static extern int SetInteractionConfigurationInteractionContext(IntPtr interactionContext, uint configurationCount, IntPtr configuration);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NInput_SetInteractionConfigurationInteractionContext' -Namespace Win32 -PassThru
# $api::SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration)#uselib "NInput.dll"
#func global SetInteractionConfigurationInteractionContext "SetInteractionConfigurationInteractionContext" sptr, sptr, sptr
; SetInteractionConfigurationInteractionContext interactionContext, configurationCount, varptr(configuration) ; 戻り値は stat
; interactionContext : HINTERACTIONCONTEXT -> "sptr"
; configurationCount : DWORD -> "sptr"
; configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NInput.dll" #cfunc global SetInteractionConfigurationInteractionContext "SetInteractionConfigurationInteractionContext" sptr, int, var ; res = SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration) ; interactionContext : HINTERACTIONCONTEXT -> "sptr" ; configurationCount : DWORD -> "int" ; configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NInput.dll" #cfunc global SetInteractionConfigurationInteractionContext "SetInteractionConfigurationInteractionContext" sptr, int, sptr ; res = SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, varptr(configuration)) ; interactionContext : HINTERACTIONCONTEXT -> "sptr" ; configurationCount : DWORD -> "int" ; configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SetInteractionConfigurationInteractionContext(HINTERACTIONCONTEXT interactionContext, DWORD configurationCount, INTERACTION_CONTEXT_CONFIGURATION* configuration) #uselib "NInput.dll" #cfunc global SetInteractionConfigurationInteractionContext "SetInteractionConfigurationInteractionContext" intptr, int, var ; res = SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration) ; interactionContext : HINTERACTIONCONTEXT -> "intptr" ; configurationCount : DWORD -> "int" ; configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SetInteractionConfigurationInteractionContext(HINTERACTIONCONTEXT interactionContext, DWORD configurationCount, INTERACTION_CONTEXT_CONFIGURATION* configuration) #uselib "NInput.dll" #cfunc global SetInteractionConfigurationInteractionContext "SetInteractionConfigurationInteractionContext" intptr, int, intptr ; res = SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, varptr(configuration)) ; interactionContext : HINTERACTIONCONTEXT -> "intptr" ; configurationCount : DWORD -> "int" ; configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ninput = windows.NewLazySystemDLL("NInput.dll")
procSetInteractionConfigurationInteractionContext = ninput.NewProc("SetInteractionConfigurationInteractionContext")
)
// interactionContext (HINTERACTIONCONTEXT), configurationCount (DWORD), configuration (INTERACTION_CONTEXT_CONFIGURATION*)
r1, _, err := procSetInteractionConfigurationInteractionContext.Call(
uintptr(interactionContext),
uintptr(configurationCount),
uintptr(configuration),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SetInteractionConfigurationInteractionContext(
interactionContext: THandle; // HINTERACTIONCONTEXT
configurationCount: DWORD; // DWORD
configuration: Pointer // INTERACTION_CONTEXT_CONFIGURATION*
): Integer; stdcall;
external 'NInput.dll' name 'SetInteractionConfigurationInteractionContext';result := DllCall("NInput\SetInteractionConfigurationInteractionContext"
, "Ptr", interactionContext ; HINTERACTIONCONTEXT
, "UInt", configurationCount ; DWORD
, "Ptr", configuration ; INTERACTION_CONTEXT_CONFIGURATION*
, "Int") ; return: HRESULT●SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration) = DLL("NInput.dll", "int SetInteractionConfigurationInteractionContext(void*, dword, void*)")
# 呼び出し: SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration)
# interactionContext : HINTERACTIONCONTEXT -> "void*"
# configurationCount : DWORD -> "dword"
# configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ninput" fn SetInteractionConfigurationInteractionContext(
interactionContext: ?*anyopaque, // HINTERACTIONCONTEXT
configurationCount: u32, // DWORD
configuration: [*c]INTERACTION_CONTEXT_CONFIGURATION // INTERACTION_CONTEXT_CONFIGURATION*
) callconv(std.os.windows.WINAPI) i32;proc SetInteractionConfigurationInteractionContext(
interactionContext: pointer, # HINTERACTIONCONTEXT
configurationCount: uint32, # DWORD
configuration: ptr INTERACTION_CONTEXT_CONFIGURATION # INTERACTION_CONTEXT_CONFIGURATION*
): int32 {.importc: "SetInteractionConfigurationInteractionContext", stdcall, dynlib: "NInput.dll".}pragma(lib, "ninput");
extern(Windows)
int SetInteractionConfigurationInteractionContext(
void* interactionContext, // HINTERACTIONCONTEXT
uint configurationCount, // DWORD
INTERACTION_CONTEXT_CONFIGURATION* configuration // INTERACTION_CONTEXT_CONFIGURATION*
);ccall((:SetInteractionConfigurationInteractionContext, "NInput.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Ptr{INTERACTION_CONTEXT_CONFIGURATION}),
interactionContext, configurationCount, configuration)
# interactionContext : HINTERACTIONCONTEXT -> Ptr{Cvoid}
# configurationCount : DWORD -> UInt32
# configuration : INTERACTION_CONTEXT_CONFIGURATION* -> Ptr{INTERACTION_CONTEXT_CONFIGURATION}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetInteractionConfigurationInteractionContext(
void* interactionContext,
uint32_t configurationCount,
void* configuration);
]]
local ninput = ffi.load("ninput")
-- ninput.SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration)
-- interactionContext : HINTERACTIONCONTEXT
-- configurationCount : DWORD
-- configuration : INTERACTION_CONTEXT_CONFIGURATION*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NInput.dll');
const SetInteractionConfigurationInteractionContext = lib.func('__stdcall', 'SetInteractionConfigurationInteractionContext', 'int32_t', ['void *', 'uint32_t', 'void *']);
// SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration)
// interactionContext : HINTERACTIONCONTEXT -> 'void *'
// configurationCount : DWORD -> 'uint32_t'
// configuration : INTERACTION_CONTEXT_CONFIGURATION* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NInput.dll", {
SetInteractionConfigurationInteractionContext: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration)
// interactionContext : HINTERACTIONCONTEXT -> "pointer"
// configurationCount : DWORD -> "u32"
// configuration : INTERACTION_CONTEXT_CONFIGURATION* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetInteractionConfigurationInteractionContext(
void* interactionContext,
uint32_t configurationCount,
void* configuration);
C, "NInput.dll");
// $ffi->SetInteractionConfigurationInteractionContext(interactionContext, configurationCount, configuration);
// interactionContext : HINTERACTIONCONTEXT
// configurationCount : DWORD
// configuration : INTERACTION_CONTEXT_CONFIGURATION*
// 構造体/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 Ninput extends StdCallLibrary {
Ninput INSTANCE = Native.load("ninput", Ninput.class);
int SetInteractionConfigurationInteractionContext(
Pointer interactionContext, // HINTERACTIONCONTEXT
int configurationCount, // DWORD
Pointer configuration // INTERACTION_CONTEXT_CONFIGURATION*
);
}@[Link("ninput")]
lib LibNInput
fun SetInteractionConfigurationInteractionContext = SetInteractionConfigurationInteractionContext(
interactionContext : Void*, # HINTERACTIONCONTEXT
configurationCount : UInt32, # DWORD
configuration : INTERACTION_CONTEXT_CONFIGURATION* # INTERACTION_CONTEXT_CONFIGURATION*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetInteractionConfigurationInteractionContextNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>);
typedef SetInteractionConfigurationInteractionContextDart = int Function(Pointer<Void>, int, Pointer<Void>);
final SetInteractionConfigurationInteractionContext = DynamicLibrary.open('NInput.dll')
.lookupFunction<SetInteractionConfigurationInteractionContextNative, SetInteractionConfigurationInteractionContextDart>('SetInteractionConfigurationInteractionContext');
// interactionContext : HINTERACTIONCONTEXT -> Pointer<Void>
// configurationCount : DWORD -> Uint32
// configuration : INTERACTION_CONTEXT_CONFIGURATION* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetInteractionConfigurationInteractionContext(
interactionContext: THandle; // HINTERACTIONCONTEXT
configurationCount: DWORD; // DWORD
configuration: Pointer // INTERACTION_CONTEXT_CONFIGURATION*
): Integer; stdcall;
external 'NInput.dll' name 'SetInteractionConfigurationInteractionContext';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetInteractionConfigurationInteractionContext"
c_SetInteractionConfigurationInteractionContext :: Ptr () -> Word32 -> Ptr () -> IO Int32
-- interactionContext : HINTERACTIONCONTEXT -> Ptr ()
-- configurationCount : DWORD -> Word32
-- configuration : INTERACTION_CONTEXT_CONFIGURATION* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setinteractionconfigurationinteractioncontext =
foreign "SetInteractionConfigurationInteractionContext"
((ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* interactionContext : HINTERACTIONCONTEXT -> (ptr void) *)
(* configurationCount : DWORD -> uint32_t *)
(* configuration : INTERACTION_CONTEXT_CONFIGURATION* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ninput (t "NInput.dll"))
(cffi:use-foreign-library ninput)
(cffi:defcfun ("SetInteractionConfigurationInteractionContext" set-interaction-configuration-interaction-context :convention :stdcall) :int32
(interaction-context :pointer) ; HINTERACTIONCONTEXT
(configuration-count :uint32) ; DWORD
(configuration :pointer)) ; INTERACTION_CONTEXT_CONFIGURATION*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetInteractionConfigurationInteractionContext = Win32::API::More->new('NInput',
'int SetInteractionConfigurationInteractionContext(HANDLE interactionContext, DWORD configurationCount, LPVOID configuration)');
# my $ret = $SetInteractionConfigurationInteractionContext->Call($interactionContext, $configurationCount, $configuration);
# interactionContext : HINTERACTIONCONTEXT -> HANDLE
# configurationCount : DWORD -> DWORD
# configuration : INTERACTION_CONTEXT_CONFIGURATION* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。