ホーム › System.StationsAndDesktops › GetUserObjectInformationA
GetUserObjectInformationA
関数ウィンドウステーションやデスクトップの情報を取得する。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL GetUserObjectInformationA(
HANDLE hObj,
USER_OBJECT_INFORMATION_INDEX nIndex,
void* pvInfo, // optional
DWORD nLength,
DWORD* lpnLengthNeeded // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hObj | HANDLE | in |
| nIndex | USER_OBJECT_INFORMATION_INDEX | in |
| pvInfo | void* | outoptional |
| nLength | DWORD | in |
| lpnLengthNeeded | DWORD* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL GetUserObjectInformationA(
HANDLE hObj,
USER_OBJECT_INFORMATION_INDEX nIndex,
void* pvInfo, // optional
DWORD nLength,
DWORD* lpnLengthNeeded // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GetUserObjectInformationA(
IntPtr hObj, // HANDLE
int nIndex, // USER_OBJECT_INFORMATION_INDEX
IntPtr pvInfo, // void* optional, out
uint nLength, // DWORD
IntPtr lpnLengthNeeded // DWORD* optional, out
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetUserObjectInformationA(
hObj As IntPtr, ' HANDLE
nIndex As Integer, ' USER_OBJECT_INFORMATION_INDEX
pvInfo As IntPtr, ' void* optional, out
nLength As UInteger, ' DWORD
lpnLengthNeeded As IntPtr ' DWORD* optional, out
) As Boolean
End Function' hObj : HANDLE
' nIndex : USER_OBJECT_INFORMATION_INDEX
' pvInfo : void* optional, out
' nLength : DWORD
' lpnLengthNeeded : DWORD* optional, out
Declare PtrSafe Function GetUserObjectInformationA Lib "user32" ( _
ByVal hObj As LongPtr, _
ByVal nIndex As Long, _
ByVal pvInfo As LongPtr, _
ByVal nLength As Long, _
ByVal lpnLengthNeeded As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetUserObjectInformationA = ctypes.windll.user32.GetUserObjectInformationA
GetUserObjectInformationA.restype = wintypes.BOOL
GetUserObjectInformationA.argtypes = [
wintypes.HANDLE, # hObj : HANDLE
ctypes.c_int, # nIndex : USER_OBJECT_INFORMATION_INDEX
ctypes.POINTER(None), # pvInfo : void* optional, out
wintypes.DWORD, # nLength : DWORD
ctypes.POINTER(wintypes.DWORD), # lpnLengthNeeded : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetUserObjectInformationA = Fiddle::Function.new(
lib['GetUserObjectInformationA'],
[
Fiddle::TYPE_VOIDP, # hObj : HANDLE
Fiddle::TYPE_INT, # nIndex : USER_OBJECT_INFORMATION_INDEX
Fiddle::TYPE_VOIDP, # pvInfo : void* optional, out
-Fiddle::TYPE_INT, # nLength : DWORD
Fiddle::TYPE_VOIDP, # lpnLengthNeeded : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetUserObjectInformationA(
hObj: *mut core::ffi::c_void, // HANDLE
nIndex: i32, // USER_OBJECT_INFORMATION_INDEX
pvInfo: *mut (), // void* optional, out
nLength: u32, // DWORD
lpnLengthNeeded: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool GetUserObjectInformationA(IntPtr hObj, int nIndex, IntPtr pvInfo, uint nLength, IntPtr lpnLengthNeeded);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetUserObjectInformationA' -Namespace Win32 -PassThru
# $api::GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded)#uselib "USER32.dll"
#func global GetUserObjectInformationA "GetUserObjectInformationA" sptr, sptr, sptr, sptr, sptr
; GetUserObjectInformationA hObj, nIndex, pvInfo, nLength, varptr(lpnLengthNeeded) ; 戻り値は stat
; hObj : HANDLE -> "sptr"
; nIndex : USER_OBJECT_INFORMATION_INDEX -> "sptr"
; pvInfo : void* optional, out -> "sptr"
; nLength : DWORD -> "sptr"
; lpnLengthNeeded : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetUserObjectInformationA "GetUserObjectInformationA" sptr, int, sptr, int, var ; res = GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded) ; hObj : HANDLE -> "sptr" ; nIndex : USER_OBJECT_INFORMATION_INDEX -> "int" ; pvInfo : void* optional, out -> "sptr" ; nLength : DWORD -> "int" ; lpnLengthNeeded : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetUserObjectInformationA "GetUserObjectInformationA" sptr, int, sptr, int, sptr ; res = GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, varptr(lpnLengthNeeded)) ; hObj : HANDLE -> "sptr" ; nIndex : USER_OBJECT_INFORMATION_INDEX -> "int" ; pvInfo : void* optional, out -> "sptr" ; nLength : DWORD -> "int" ; lpnLengthNeeded : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetUserObjectInformationA(HANDLE hObj, USER_OBJECT_INFORMATION_INDEX nIndex, void* pvInfo, DWORD nLength, DWORD* lpnLengthNeeded) #uselib "USER32.dll" #cfunc global GetUserObjectInformationA "GetUserObjectInformationA" intptr, int, intptr, int, var ; res = GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded) ; hObj : HANDLE -> "intptr" ; nIndex : USER_OBJECT_INFORMATION_INDEX -> "int" ; pvInfo : void* optional, out -> "intptr" ; nLength : DWORD -> "int" ; lpnLengthNeeded : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetUserObjectInformationA(HANDLE hObj, USER_OBJECT_INFORMATION_INDEX nIndex, void* pvInfo, DWORD nLength, DWORD* lpnLengthNeeded) #uselib "USER32.dll" #cfunc global GetUserObjectInformationA "GetUserObjectInformationA" intptr, int, intptr, int, intptr ; res = GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, varptr(lpnLengthNeeded)) ; hObj : HANDLE -> "intptr" ; nIndex : USER_OBJECT_INFORMATION_INDEX -> "int" ; pvInfo : void* optional, out -> "intptr" ; nLength : DWORD -> "int" ; lpnLengthNeeded : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetUserObjectInformationA = user32.NewProc("GetUserObjectInformationA")
)
// hObj (HANDLE), nIndex (USER_OBJECT_INFORMATION_INDEX), pvInfo (void* optional, out), nLength (DWORD), lpnLengthNeeded (DWORD* optional, out)
r1, _, err := procGetUserObjectInformationA.Call(
uintptr(hObj),
uintptr(nIndex),
uintptr(pvInfo),
uintptr(nLength),
uintptr(lpnLengthNeeded),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetUserObjectInformationA(
hObj: THandle; // HANDLE
nIndex: Integer; // USER_OBJECT_INFORMATION_INDEX
pvInfo: Pointer; // void* optional, out
nLength: DWORD; // DWORD
lpnLengthNeeded: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'USER32.dll' name 'GetUserObjectInformationA';result := DllCall("USER32\GetUserObjectInformationA"
, "Ptr", hObj ; HANDLE
, "Int", nIndex ; USER_OBJECT_INFORMATION_INDEX
, "Ptr", pvInfo ; void* optional, out
, "UInt", nLength ; DWORD
, "Ptr", lpnLengthNeeded ; DWORD* optional, out
, "Int") ; return: BOOL●GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded) = DLL("USER32.dll", "bool GetUserObjectInformationA(void*, int, void*, dword, void*)")
# 呼び出し: GetUserObjectInformationA(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded)
# hObj : HANDLE -> "void*"
# nIndex : USER_OBJECT_INFORMATION_INDEX -> "int"
# pvInfo : void* optional, out -> "void*"
# nLength : DWORD -> "dword"
# lpnLengthNeeded : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。