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

SetPropertyInteractionContext

関数
インタラクションコンテキストのプロパティ値を設定する。
DLLNInput.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SetPropertyInteractionContext(
    HINTERACTIONCONTEXT interactionContext,
    INTERACTION_CONTEXT_PROPERTY contextProperty,
    DWORD value
);

パラメーター

名前方向説明
interactionContextHINTERACTIONCONTEXTin対象インタラクションコンテキストのハンドルを指定する。
contextPropertyINTERACTION_CONTEXT_PROPERTYin設定するプロパティ種別を示すINTERACTION_CONTEXT_PROPERTYを指定する。
valueDWORDinプロパティに設定する値を指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SetPropertyInteractionContext(
    HINTERACTIONCONTEXT interactionContext,
    INTERACTION_CONTEXT_PROPERTY contextProperty,
    DWORD value
);
[DllImport("NInput.dll", ExactSpelling = true)]
static extern int SetPropertyInteractionContext(
    IntPtr interactionContext,   // HINTERACTIONCONTEXT
    int contextProperty,   // INTERACTION_CONTEXT_PROPERTY
    uint value   // DWORD
);
<DllImport("NInput.dll", ExactSpelling:=True)>
Public Shared Function SetPropertyInteractionContext(
    interactionContext As IntPtr,   ' HINTERACTIONCONTEXT
    contextProperty As Integer,   ' INTERACTION_CONTEXT_PROPERTY
    value As UInteger   ' DWORD
) As Integer
End Function
' interactionContext : HINTERACTIONCONTEXT
' contextProperty : INTERACTION_CONTEXT_PROPERTY
' value : DWORD
Declare PtrSafe Function SetPropertyInteractionContext Lib "ninput" ( _
    ByVal interactionContext As LongPtr, _
    ByVal contextProperty As Long, _
    ByVal value As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetPropertyInteractionContext = ctypes.windll.ninput.SetPropertyInteractionContext
SetPropertyInteractionContext.restype = ctypes.c_int
SetPropertyInteractionContext.argtypes = [
    wintypes.HANDLE,  # interactionContext : HINTERACTIONCONTEXT
    ctypes.c_int,  # contextProperty : INTERACTION_CONTEXT_PROPERTY
    wintypes.DWORD,  # value : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NInput.dll')
SetPropertyInteractionContext = Fiddle::Function.new(
  lib['SetPropertyInteractionContext'],
  [
    Fiddle::TYPE_VOIDP,  # interactionContext : HINTERACTIONCONTEXT
    Fiddle::TYPE_INT,  # contextProperty : INTERACTION_CONTEXT_PROPERTY
    -Fiddle::TYPE_INT,  # value : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "ninput")]
extern "system" {
    fn SetPropertyInteractionContext(
        interactionContext: *mut core::ffi::c_void,  // HINTERACTIONCONTEXT
        contextProperty: i32,  // INTERACTION_CONTEXT_PROPERTY
        value: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NInput.dll")]
public static extern int SetPropertyInteractionContext(IntPtr interactionContext, int contextProperty, uint value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NInput_SetPropertyInteractionContext' -Namespace Win32 -PassThru
# $api::SetPropertyInteractionContext(interactionContext, contextProperty, value)
#uselib "NInput.dll"
#func global SetPropertyInteractionContext "SetPropertyInteractionContext" sptr, sptr, sptr
; SetPropertyInteractionContext interactionContext, contextProperty, value   ; 戻り値は stat
; interactionContext : HINTERACTIONCONTEXT -> "sptr"
; contextProperty : INTERACTION_CONTEXT_PROPERTY -> "sptr"
; value : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NInput.dll"
#cfunc global SetPropertyInteractionContext "SetPropertyInteractionContext" sptr, int, int
; res = SetPropertyInteractionContext(interactionContext, contextProperty, value)
; interactionContext : HINTERACTIONCONTEXT -> "sptr"
; contextProperty : INTERACTION_CONTEXT_PROPERTY -> "int"
; value : DWORD -> "int"
; HRESULT SetPropertyInteractionContext(HINTERACTIONCONTEXT interactionContext, INTERACTION_CONTEXT_PROPERTY contextProperty, DWORD value)
#uselib "NInput.dll"
#cfunc global SetPropertyInteractionContext "SetPropertyInteractionContext" intptr, int, int
; res = SetPropertyInteractionContext(interactionContext, contextProperty, value)
; interactionContext : HINTERACTIONCONTEXT -> "intptr"
; contextProperty : INTERACTION_CONTEXT_PROPERTY -> "int"
; value : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ninput = windows.NewLazySystemDLL("NInput.dll")
	procSetPropertyInteractionContext = ninput.NewProc("SetPropertyInteractionContext")
)

// interactionContext (HINTERACTIONCONTEXT), contextProperty (INTERACTION_CONTEXT_PROPERTY), value (DWORD)
r1, _, err := procSetPropertyInteractionContext.Call(
	uintptr(interactionContext),
	uintptr(contextProperty),
	uintptr(value),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SetPropertyInteractionContext(
  interactionContext: THandle;   // HINTERACTIONCONTEXT
  contextProperty: Integer;   // INTERACTION_CONTEXT_PROPERTY
  value: DWORD   // DWORD
): Integer; stdcall;
  external 'NInput.dll' name 'SetPropertyInteractionContext';
result := DllCall("NInput\SetPropertyInteractionContext"
    , "Ptr", interactionContext   ; HINTERACTIONCONTEXT
    , "Int", contextProperty   ; INTERACTION_CONTEXT_PROPERTY
    , "UInt", value   ; DWORD
    , "Int")   ; return: HRESULT
●SetPropertyInteractionContext(interactionContext, contextProperty, value) = DLL("NInput.dll", "int SetPropertyInteractionContext(void*, int, dword)")
# 呼び出し: SetPropertyInteractionContext(interactionContext, contextProperty, value)
# interactionContext : HINTERACTIONCONTEXT -> "void*"
# contextProperty : INTERACTION_CONTEXT_PROPERTY -> "int"
# value : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SetPropertyInteractionContextNative = Int32 Function(Pointer<Void>, Int32, Uint32);
typedef SetPropertyInteractionContextDart = int Function(Pointer<Void>, int, int);
final SetPropertyInteractionContext = DynamicLibrary.open('NInput.dll')
    .lookupFunction<SetPropertyInteractionContextNative, SetPropertyInteractionContextDart>('SetPropertyInteractionContext');
// interactionContext : HINTERACTIONCONTEXT -> Pointer<Void>
// contextProperty : INTERACTION_CONTEXT_PROPERTY -> Int32
// value : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetPropertyInteractionContext(
  interactionContext: THandle;   // HINTERACTIONCONTEXT
  contextProperty: Integer;   // INTERACTION_CONTEXT_PROPERTY
  value: DWORD   // DWORD
): Integer; stdcall;
  external 'NInput.dll' name 'SetPropertyInteractionContext';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetPropertyInteractionContext"
  c_SetPropertyInteractionContext :: Ptr () -> Int32 -> Word32 -> IO Int32
-- interactionContext : HINTERACTIONCONTEXT -> Ptr ()
-- contextProperty : INTERACTION_CONTEXT_PROPERTY -> Int32
-- value : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setpropertyinteractioncontext =
  foreign "SetPropertyInteractionContext"
    ((ptr void) @-> int32_t @-> uint32_t @-> returning int32_t)
(* interactionContext : HINTERACTIONCONTEXT -> (ptr void) *)
(* contextProperty : INTERACTION_CONTEXT_PROPERTY -> int32_t *)
(* value : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ninput (t "NInput.dll"))
(cffi:use-foreign-library ninput)

(cffi:defcfun ("SetPropertyInteractionContext" set-property-interaction-context :convention :stdcall) :int32
  (interaction-context :pointer)   ; HINTERACTIONCONTEXT
  (context-property :int32)   ; INTERACTION_CONTEXT_PROPERTY
  (value :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetPropertyInteractionContext = Win32::API::More->new('NInput',
    'int SetPropertyInteractionContext(HANDLE interactionContext, int contextProperty, DWORD value)');
# my $ret = $SetPropertyInteractionContext->Call($interactionContext, $contextProperty, $value);
# interactionContext : HINTERACTIONCONTEXT -> HANDLE
# contextProperty : INTERACTION_CONTEXT_PROPERTY -> int
# value : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型