Win32 API 日本語リファレンス
ホームSystem.StationsAndDesktops › SetUserObjectInformationA

SetUserObjectInformationA

関数
ユーザーオブジェクトの情報を設定する。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL SetUserObjectInformationA(
    HANDLE hObj,
    INT nIndex,
    void* pvInfo,
    DWORD nLength
);

パラメーター

名前方向
hObjHANDLEin
nIndexINTin
pvInfovoid*in
nLengthDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL SetUserObjectInformationA(
    HANDLE hObj,
    INT nIndex,
    void* pvInfo,
    DWORD nLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetUserObjectInformationA(
    IntPtr hObj,   // HANDLE
    int nIndex,   // INT
    IntPtr pvInfo,   // void*
    uint nLength   // DWORD
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetUserObjectInformationA(
    hObj As IntPtr,   ' HANDLE
    nIndex As Integer,   ' INT
    pvInfo As IntPtr,   ' void*
    nLength As UInteger   ' DWORD
) As Boolean
End Function
' hObj : HANDLE
' nIndex : INT
' pvInfo : void*
' nLength : DWORD
Declare PtrSafe Function SetUserObjectInformationA Lib "user32" ( _
    ByVal hObj As LongPtr, _
    ByVal nIndex As Long, _
    ByVal pvInfo As LongPtr, _
    ByVal nLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetUserObjectInformationA = ctypes.windll.user32.SetUserObjectInformationA
SetUserObjectInformationA.restype = wintypes.BOOL
SetUserObjectInformationA.argtypes = [
    wintypes.HANDLE,  # hObj : HANDLE
    ctypes.c_int,  # nIndex : INT
    ctypes.POINTER(None),  # pvInfo : void*
    wintypes.DWORD,  # nLength : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetUserObjectInformationA = Fiddle::Function.new(
  lib['SetUserObjectInformationA'],
  [
    Fiddle::TYPE_VOIDP,  # hObj : HANDLE
    Fiddle::TYPE_INT,  # nIndex : INT
    Fiddle::TYPE_VOIDP,  # pvInfo : void*
    -Fiddle::TYPE_INT,  # nLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn SetUserObjectInformationA(
        hObj: *mut core::ffi::c_void,  // HANDLE
        nIndex: i32,  // INT
        pvInfo: *mut (),  // void*
        nLength: u32  // DWORD
    ) -> 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 SetUserObjectInformationA(IntPtr hObj, int nIndex, IntPtr pvInfo, uint nLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetUserObjectInformationA' -Namespace Win32 -PassThru
# $api::SetUserObjectInformationA(hObj, nIndex, pvInfo, nLength)
#uselib "USER32.dll"
#func global SetUserObjectInformationA "SetUserObjectInformationA" sptr, sptr, sptr, sptr
; SetUserObjectInformationA hObj, nIndex, pvInfo, nLength   ; 戻り値は stat
; hObj : HANDLE -> "sptr"
; nIndex : INT -> "sptr"
; pvInfo : void* -> "sptr"
; nLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global SetUserObjectInformationA "SetUserObjectInformationA" sptr, int, sptr, int
; res = SetUserObjectInformationA(hObj, nIndex, pvInfo, nLength)
; hObj : HANDLE -> "sptr"
; nIndex : INT -> "int"
; pvInfo : void* -> "sptr"
; nLength : DWORD -> "int"
; BOOL SetUserObjectInformationA(HANDLE hObj, INT nIndex, void* pvInfo, DWORD nLength)
#uselib "USER32.dll"
#cfunc global SetUserObjectInformationA "SetUserObjectInformationA" intptr, int, intptr, int
; res = SetUserObjectInformationA(hObj, nIndex, pvInfo, nLength)
; hObj : HANDLE -> "intptr"
; nIndex : INT -> "int"
; pvInfo : void* -> "intptr"
; nLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetUserObjectInformationA = user32.NewProc("SetUserObjectInformationA")
)

// hObj (HANDLE), nIndex (INT), pvInfo (void*), nLength (DWORD)
r1, _, err := procSetUserObjectInformationA.Call(
	uintptr(hObj),
	uintptr(nIndex),
	uintptr(pvInfo),
	uintptr(nLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetUserObjectInformationA(
  hObj: THandle;   // HANDLE
  nIndex: Integer;   // INT
  pvInfo: Pointer;   // void*
  nLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'USER32.dll' name 'SetUserObjectInformationA';
result := DllCall("USER32\SetUserObjectInformationA"
    , "Ptr", hObj   ; HANDLE
    , "Int", nIndex   ; INT
    , "Ptr", pvInfo   ; void*
    , "UInt", nLength   ; DWORD
    , "Int")   ; return: BOOL
●SetUserObjectInformationA(hObj, nIndex, pvInfo, nLength) = DLL("USER32.dll", "bool SetUserObjectInformationA(void*, int, void*, dword)")
# 呼び出し: SetUserObjectInformationA(hObj, nIndex, pvInfo, nLength)
# hObj : HANDLE -> "void*"
# nIndex : INT -> "int"
# pvInfo : void* -> "void*"
# nLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。