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

UiaGetPropertyValue

関数
UIオートメーションノードの指定プロパティ値を取得する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT UiaGetPropertyValue(
    HUIANODE hnode,
    INT propertyId,
    VARIANT* pValue
);

パラメーター

名前方向
hnodeHUIANODEin
propertyIdINTin
pValueVARIANT*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT UiaGetPropertyValue(
    HUIANODE hnode,
    INT propertyId,
    VARIANT* pValue
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int UiaGetPropertyValue(
    IntPtr hnode,   // HUIANODE
    int propertyId,   // INT
    IntPtr pValue   // VARIANT* in/out
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function UiaGetPropertyValue(
    hnode As IntPtr,   ' HUIANODE
    propertyId As Integer,   ' INT
    pValue As IntPtr   ' VARIANT* in/out
) As Integer
End Function
' hnode : HUIANODE
' propertyId : INT
' pValue : VARIANT* in/out
Declare PtrSafe Function UiaGetPropertyValue Lib "uiautomationcore" ( _
    ByVal hnode As LongPtr, _
    ByVal propertyId As Long, _
    ByVal pValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UiaGetPropertyValue = ctypes.windll.uiautomationcore.UiaGetPropertyValue
UiaGetPropertyValue.restype = ctypes.c_int
UiaGetPropertyValue.argtypes = [
    wintypes.HANDLE,  # hnode : HUIANODE
    ctypes.c_int,  # propertyId : INT
    ctypes.c_void_p,  # pValue : VARIANT* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procUiaGetPropertyValue = uiautomationcore.NewProc("UiaGetPropertyValue")
)

// hnode (HUIANODE), propertyId (INT), pValue (VARIANT* in/out)
r1, _, err := procUiaGetPropertyValue.Call(
	uintptr(hnode),
	uintptr(propertyId),
	uintptr(pValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function UiaGetPropertyValue(
  hnode: THandle;   // HUIANODE
  propertyId: Integer;   // INT
  pValue: Pointer   // VARIANT* in/out
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'UiaGetPropertyValue';
result := DllCall("UIAutomationCore\UiaGetPropertyValue"
    , "Ptr", hnode   ; HUIANODE
    , "Int", propertyId   ; INT
    , "Ptr", pValue   ; VARIANT* in/out
    , "Int")   ; return: HRESULT
●UiaGetPropertyValue(hnode, propertyId, pValue) = DLL("UIAutomationCore.dll", "int UiaGetPropertyValue(void*, int, void*)")
# 呼び出し: UiaGetPropertyValue(hnode, propertyId, pValue)
# hnode : HUIANODE -> "void*"
# propertyId : INT -> "int"
# pValue : VARIANT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。