ホーム › UI.WindowsAndMessaging › GetAltTabInfoW
GetAltTabInfoW
関数Alt+Tab切替画面の項目情報を取得する(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
BOOL GetAltTabInfoW(
HWND hwnd, // optional
INT iItem,
ALTTABINFO* pati,
LPWSTR pszItemText, // optional
DWORD cchItemText
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | inoptional |
| iItem | INT | in |
| pati | ALTTABINFO* | inout |
| pszItemText | LPWSTR | outoptional |
| cchItemText | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
BOOL GetAltTabInfoW(
HWND hwnd, // optional
INT iItem,
ALTTABINFO* pati,
LPWSTR pszItemText, // optional
DWORD cchItemText
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool GetAltTabInfoW(
IntPtr hwnd, // HWND optional
int iItem, // INT
IntPtr pati, // ALTTABINFO* in/out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszItemText, // LPWSTR optional, out
uint cchItemText // DWORD
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetAltTabInfoW(
hwnd As IntPtr, ' HWND optional
iItem As Integer, ' INT
pati As IntPtr, ' ALTTABINFO* in/out
<MarshalAs(UnmanagedType.LPWStr)> pszItemText As System.Text.StringBuilder, ' LPWSTR optional, out
cchItemText As UInteger ' DWORD
) As Boolean
End Function' hwnd : HWND optional
' iItem : INT
' pati : ALTTABINFO* in/out
' pszItemText : LPWSTR optional, out
' cchItemText : DWORD
Declare PtrSafe Function GetAltTabInfoW Lib "user32" ( _
ByVal hwnd As LongPtr, _
ByVal iItem As Long, _
ByVal pati As LongPtr, _
ByVal pszItemText As LongPtr, _
ByVal cchItemText As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetAltTabInfoW = ctypes.windll.user32.GetAltTabInfoW
GetAltTabInfoW.restype = wintypes.BOOL
GetAltTabInfoW.argtypes = [
wintypes.HANDLE, # hwnd : HWND optional
ctypes.c_int, # iItem : INT
ctypes.c_void_p, # pati : ALTTABINFO* in/out
wintypes.LPWSTR, # pszItemText : LPWSTR optional, out
wintypes.DWORD, # cchItemText : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetAltTabInfoW = Fiddle::Function.new(
lib['GetAltTabInfoW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_INT, # iItem : INT
Fiddle::TYPE_VOIDP, # pati : ALTTABINFO* in/out
Fiddle::TYPE_VOIDP, # pszItemText : LPWSTR optional, out
-Fiddle::TYPE_INT, # cchItemText : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn GetAltTabInfoW(
hwnd: *mut core::ffi::c_void, // HWND optional
iItem: i32, // INT
pati: *mut ALTTABINFO, // ALTTABINFO* in/out
pszItemText: *mut u16, // LPWSTR optional, out
cchItemText: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool GetAltTabInfoW(IntPtr hwnd, int iItem, IntPtr pati, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszItemText, uint cchItemText);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetAltTabInfoW' -Namespace Win32 -PassThru
# $api::GetAltTabInfoW(hwnd, iItem, pati, pszItemText, cchItemText)#uselib "USER32.dll"
#func global GetAltTabInfoW "GetAltTabInfoW" wptr, wptr, wptr, wptr, wptr
; GetAltTabInfoW hwnd, iItem, varptr(pati), varptr(pszItemText), cchItemText ; 戻り値は stat
; hwnd : HWND optional -> "wptr"
; iItem : INT -> "wptr"
; pati : ALTTABINFO* in/out -> "wptr"
; pszItemText : LPWSTR optional, out -> "wptr"
; cchItemText : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetAltTabInfoW "GetAltTabInfoW" sptr, int, var, var, int ; res = GetAltTabInfoW(hwnd, iItem, pati, pszItemText, cchItemText) ; hwnd : HWND optional -> "sptr" ; iItem : INT -> "int" ; pati : ALTTABINFO* in/out -> "var" ; pszItemText : LPWSTR optional, out -> "var" ; cchItemText : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetAltTabInfoW "GetAltTabInfoW" sptr, int, sptr, sptr, int ; res = GetAltTabInfoW(hwnd, iItem, varptr(pati), varptr(pszItemText), cchItemText) ; hwnd : HWND optional -> "sptr" ; iItem : INT -> "int" ; pati : ALTTABINFO* in/out -> "sptr" ; pszItemText : LPWSTR optional, out -> "sptr" ; cchItemText : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetAltTabInfoW(HWND hwnd, INT iItem, ALTTABINFO* pati, LPWSTR pszItemText, DWORD cchItemText) #uselib "USER32.dll" #cfunc global GetAltTabInfoW "GetAltTabInfoW" intptr, int, var, var, int ; res = GetAltTabInfoW(hwnd, iItem, pati, pszItemText, cchItemText) ; hwnd : HWND optional -> "intptr" ; iItem : INT -> "int" ; pati : ALTTABINFO* in/out -> "var" ; pszItemText : LPWSTR optional, out -> "var" ; cchItemText : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetAltTabInfoW(HWND hwnd, INT iItem, ALTTABINFO* pati, LPWSTR pszItemText, DWORD cchItemText) #uselib "USER32.dll" #cfunc global GetAltTabInfoW "GetAltTabInfoW" intptr, int, intptr, intptr, int ; res = GetAltTabInfoW(hwnd, iItem, varptr(pati), varptr(pszItemText), cchItemText) ; hwnd : HWND optional -> "intptr" ; iItem : INT -> "int" ; pati : ALTTABINFO* in/out -> "intptr" ; pszItemText : LPWSTR optional, out -> "intptr" ; cchItemText : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetAltTabInfoW = user32.NewProc("GetAltTabInfoW")
)
// hwnd (HWND optional), iItem (INT), pati (ALTTABINFO* in/out), pszItemText (LPWSTR optional, out), cchItemText (DWORD)
r1, _, err := procGetAltTabInfoW.Call(
uintptr(hwnd),
uintptr(iItem),
uintptr(pati),
uintptr(pszItemText),
uintptr(cchItemText),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetAltTabInfoW(
hwnd: THandle; // HWND optional
iItem: Integer; // INT
pati: Pointer; // ALTTABINFO* in/out
pszItemText: PWideChar; // LPWSTR optional, out
cchItemText: DWORD // DWORD
): BOOL; stdcall;
external 'USER32.dll' name 'GetAltTabInfoW';result := DllCall("USER32\GetAltTabInfoW"
, "Ptr", hwnd ; HWND optional
, "Int", iItem ; INT
, "Ptr", pati ; ALTTABINFO* in/out
, "Ptr", pszItemText ; LPWSTR optional, out
, "UInt", cchItemText ; DWORD
, "Int") ; return: BOOL●GetAltTabInfoW(hwnd, iItem, pati, pszItemText, cchItemText) = DLL("USER32.dll", "bool GetAltTabInfoW(void*, int, void*, char*, dword)")
# 呼び出し: GetAltTabInfoW(hwnd, iItem, pati, pszItemText, cchItemText)
# hwnd : HWND optional -> "void*"
# iItem : INT -> "int"
# pati : ALTTABINFO* in/out -> "void*"
# pszItemText : LPWSTR optional, out -> "char*"
# cchItemText : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。