ホーム › System.StationsAndDesktops › SetUserObjectInformationW
SetUserObjectInformationW
関数ユーザーオブジェクトの情報を設定する。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
BOOL SetUserObjectInformationW(
HANDLE hObj,
INT nIndex,
void* pvInfo,
DWORD nLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hObj | HANDLE | in |
| nIndex | INT | in |
| pvInfo | void* | in |
| nLength | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
BOOL SetUserObjectInformationW(
HANDLE hObj,
INT nIndex,
void* pvInfo,
DWORD nLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetUserObjectInformationW(
IntPtr hObj, // HANDLE
int nIndex, // INT
IntPtr pvInfo, // void*
uint nLength // DWORD
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetUserObjectInformationW(
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 SetUserObjectInformationW Lib "user32" ( _
ByVal hObj As LongPtr, _
ByVal nIndex As Long, _
ByVal pvInfo As LongPtr, _
ByVal nLength 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
SetUserObjectInformationW = ctypes.windll.user32.SetUserObjectInformationW
SetUserObjectInformationW.restype = wintypes.BOOL
SetUserObjectInformationW.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')
SetUserObjectInformationW = Fiddle::Function.new(
lib['SetUserObjectInformationW'],
[
Fiddle::TYPE_VOIDP, # hObj : HANDLE
Fiddle::TYPE_INT, # nIndex : INT
Fiddle::TYPE_VOIDP, # pvInfo : void*
-Fiddle::TYPE_INT, # nLength : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn SetUserObjectInformationW(
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.Unicode, SetLastError = true)]
public static extern bool SetUserObjectInformationW(IntPtr hObj, int nIndex, IntPtr pvInfo, uint nLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetUserObjectInformationW' -Namespace Win32 -PassThru
# $api::SetUserObjectInformationW(hObj, nIndex, pvInfo, nLength)#uselib "USER32.dll"
#func global SetUserObjectInformationW "SetUserObjectInformationW" wptr, wptr, wptr, wptr
; SetUserObjectInformationW hObj, nIndex, pvInfo, nLength ; 戻り値は stat
; hObj : HANDLE -> "wptr"
; nIndex : INT -> "wptr"
; pvInfo : void* -> "wptr"
; nLength : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetUserObjectInformationW "SetUserObjectInformationW" sptr, int, sptr, int
; res = SetUserObjectInformationW(hObj, nIndex, pvInfo, nLength)
; hObj : HANDLE -> "sptr"
; nIndex : INT -> "int"
; pvInfo : void* -> "sptr"
; nLength : DWORD -> "int"; BOOL SetUserObjectInformationW(HANDLE hObj, INT nIndex, void* pvInfo, DWORD nLength)
#uselib "USER32.dll"
#cfunc global SetUserObjectInformationW "SetUserObjectInformationW" intptr, int, intptr, int
; res = SetUserObjectInformationW(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")
procSetUserObjectInformationW = user32.NewProc("SetUserObjectInformationW")
)
// hObj (HANDLE), nIndex (INT), pvInfo (void*), nLength (DWORD)
r1, _, err := procSetUserObjectInformationW.Call(
uintptr(hObj),
uintptr(nIndex),
uintptr(pvInfo),
uintptr(nLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetUserObjectInformationW(
hObj: THandle; // HANDLE
nIndex: Integer; // INT
pvInfo: Pointer; // void*
nLength: DWORD // DWORD
): BOOL; stdcall;
external 'USER32.dll' name 'SetUserObjectInformationW';result := DllCall("USER32\SetUserObjectInformationW"
, "Ptr", hObj ; HANDLE
, "Int", nIndex ; INT
, "Ptr", pvInfo ; void*
, "UInt", nLength ; DWORD
, "Int") ; return: BOOL●SetUserObjectInformationW(hObj, nIndex, pvInfo, nLength) = DLL("USER32.dll", "bool SetUserObjectInformationW(void*, int, void*, dword)")
# 呼び出し: SetUserObjectInformationW(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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。