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

UiaGetRuntimeId

関数
UIオートメーションノードのランタイムIDを取得する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT UiaGetRuntimeId(
    HUIANODE hnode,
    SAFEARRAY** pruntimeId
);

パラメーター

名前方向説明
hnodeHUIANODEinランタイムIDを取得する対象ノードのハンドル。
pruntimeIdSAFEARRAY**inoutノードのランタイムIDを格納したSAFEARRAY(整数配列)を受け取る出力先。要素を一意に識別する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

UiaGetRuntimeId = ctypes.windll.uiautomationcore.UiaGetRuntimeId
UiaGetRuntimeId.restype = ctypes.c_int
UiaGetRuntimeId.argtypes = [
    wintypes.HANDLE,  # hnode : HUIANODE
    ctypes.c_void_p,  # pruntimeId : SAFEARRAY** in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procUiaGetRuntimeId = uiautomationcore.NewProc("UiaGetRuntimeId")
)

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

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

foreign import stdcall safe "UiaGetRuntimeId"
  c_UiaGetRuntimeId :: Ptr () -> Ptr () -> IO Int32
-- hnode : HUIANODE -> Ptr ()
-- pruntimeId : SAFEARRAY** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uiagetruntimeid =
  foreign "UiaGetRuntimeId"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* hnode : HUIANODE -> (ptr void) *)
(* pruntimeId : SAFEARRAY** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)

(cffi:defcfun ("UiaGetRuntimeId" uia-get-runtime-id :convention :stdcall) :int32
  (hnode :pointer)   ; HUIANODE
  (pruntime-id :pointer))   ; SAFEARRAY** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UiaGetRuntimeId = Win32::API::More->new('UIAutomationCore',
    'int UiaGetRuntimeId(HANDLE hnode, LPVOID pruntimeId)');
# my $ret = $UiaGetRuntimeId->Call($hnode, $pruntimeId);
# hnode : HUIANODE -> HANDLE
# pruntimeId : SAFEARRAY** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型