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

GetPropertyInteractionContext

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

シグネチャ

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

HRESULT GetPropertyInteractionContext(
    HINTERACTIONCONTEXT interactionContext,
    INTERACTION_CONTEXT_PROPERTY contextProperty,
    DWORD* value
);

パラメーター

名前方向説明
interactionContextHINTERACTIONCONTEXTin対象インタラクションコンテキストのハンドルを指定する。
contextPropertyINTERACTION_CONTEXT_PROPERTYin取得するプロパティ種別を示すINTERACTION_CONTEXT_PROPERTYを指定する。
valueDWORD*out取得したプロパティ値を受け取るDWORDへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

GetPropertyInteractionContext = ctypes.windll.ninput.GetPropertyInteractionContext
GetPropertyInteractionContext.restype = ctypes.c_int
GetPropertyInteractionContext.argtypes = [
    wintypes.HANDLE,  # interactionContext : HINTERACTIONCONTEXT
    ctypes.c_int,  # contextProperty : INTERACTION_CONTEXT_PROPERTY
    ctypes.POINTER(wintypes.DWORD),  # value : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ninput = windows.NewLazySystemDLL("NInput.dll")
	procGetPropertyInteractionContext = ninput.NewProc("GetPropertyInteractionContext")
)

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

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

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

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

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

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

関連項目

使用する型