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

UiaLookupId

関数
プロパティやパターンのGUIDから整数IDを検索する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

INT UiaLookupId(
    AutomationIdentifierType type,
    const GUID* pGuid
);

パラメーター

名前方向説明
typeAutomationIdentifierTypein検索する識別子の種別(プロパティ・パターン・イベント等)を示すAutomationIdentifierType値。
pGuidGUID*in検索対象の識別子を表すGUIDへのポインター。

戻り値の型: INT

各言語での呼び出し定義

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

INT UiaLookupId(
    AutomationIdentifierType type,
    const GUID* pGuid
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int UiaLookupId(
    int type,   // AutomationIdentifierType
    ref Guid pGuid   // GUID*
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function UiaLookupId(
    type As Integer,   ' AutomationIdentifierType
    ByRef pGuid As Guid   ' GUID*
) As Integer
End Function
' type : AutomationIdentifierType
' pGuid : GUID*
Declare PtrSafe Function UiaLookupId Lib "uiautomationcore" ( _
    ByVal type As Long, _
    ByVal pGuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UiaLookupId = ctypes.windll.uiautomationcore.UiaLookupId
UiaLookupId.restype = ctypes.c_int
UiaLookupId.argtypes = [
    ctypes.c_int,  # type : AutomationIdentifierType
    ctypes.c_void_p,  # pGuid : GUID*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procUiaLookupId = uiautomationcore.NewProc("UiaLookupId")
)

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

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

typedef UiaLookupIdNative = Int32 Function(Int32, Pointer<Void>);
typedef UiaLookupIdDart = int Function(int, Pointer<Void>);
final UiaLookupId = DynamicLibrary.open('UIAutomationCore.dll')
    .lookupFunction<UiaLookupIdNative, UiaLookupIdDart>('UiaLookupId');
// type : AutomationIdentifierType -> Int32
// pGuid : GUID* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function UiaLookupId(
  type: Integer;   // AutomationIdentifierType
  pGuid: PGUID   // GUID*
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'UiaLookupId';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "UiaLookupId"
  c_UiaLookupId :: Int32 -> Ptr () -> IO Int32
-- type : AutomationIdentifierType -> Int32
-- pGuid : GUID* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uialookupid =
  foreign "UiaLookupId"
    (int32_t @-> (ptr void) @-> returning int32_t)
(* type : AutomationIdentifierType -> int32_t *)
(* pGuid : GUID* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)

(cffi:defcfun ("UiaLookupId" uia-lookup-id :convention :stdcall) :int32
  (type :int32)   ; AutomationIdentifierType
  (p-guid :pointer))   ; GUID*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UiaLookupId = Win32::API::More->new('UIAutomationCore',
    'int UiaLookupId(int type, LPVOID pGuid)');
# my $ret = $UiaLookupId->Call($type, $pGuid);
# type : AutomationIdentifierType -> int
# pGuid : GUID* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型