GetUserObjectInformation function (Windows)

Switch View :
ScriptFree
GetUserObjectInformation function

Applies to: desktop apps only

Retrieves information about the specified window station or desktop object.

Syntax

BOOL WINAPI GetUserObjectInformation(
  __in       HANDLE hObj,
  __in       int nIndex,
  __out_opt  PVOID pvInfo,
  __in       DWORD nLength,
  __out_opt  LPDWORD lpnLengthNeeded
);

Parameters

hObj [in]

A handle to the window station or desktop object. This handle is returned by the CreateWindowStation, OpenWindowStation, CreateDesktop, or OpenDesktop function.

nIndex [in]

The information to be retrieved. The parameter can be one of the following values.

ValueMeaning
UOI_FLAGS
1

The handle flags. The pvInfo parameter must point to a USEROBJECTFLAGS structure.

UOI_HEAPSIZE
5

The size of the desktop heap, in KB, as a ULONG value. The hObj parameter must be a handle to a desktop object, otherwise, the function fails.

Windows Server 2003 and Windows XP/2000:  This value is not supported.
UOI_IO
6

TRUE if the hObj parameter is a handle to the desktop object that is receiving input from the user. FALSE otherwise.

Windows Server 2003 and Windows XP/2000:  This value is not supported.
UOI_NAME
2

The name of the object, as a string.

UOI_TYPE
3

The type name of the object, as a string.

UOI_USER_SID
4

The SID structure that identifies the user that is currently associated with the specified object. If no user is associated with the object, the value returned in the buffer pointed to by lpnLengthNeeded is zero. Note that SID is a variable length structure. You will usually make a call to GetUserObjectInformation to determine the length of the SID before retrieving its value.

 

pvInfo [out, optional]

A pointer to a buffer to receive the object information.

nLength [in]

The size of the buffer pointed to by the pvInfo parameter, in bytes.

lpnLengthNeeded [out, optional]

A pointer to a variable receiving the number of bytes required to store the requested information. If this variable's value is greater than the value of the nLength parameter when the function returns, the function returns FALSE, and none of the information is copied to the pvInfo buffer. If the value of the variable pointed to by lpnLengthNeeded is less than or equal to the value of nLength, the entire information block is copied.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

GetUserObjectInformationW (Unicode) and GetUserObjectInformationA (ANSI)

See also

CreateDesktop
CreateWindowStation
GetUserObjectSecurity
OpenDesktop
OpenWindowStation
SetUserObjectInformation
SetUserObjectSecurity
SID
USEROBJECTFLAGS
Window Station and Desktop Functions

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Community Content

dmex
C# syntax
[DllImport("user32.dll", SetLastError=true)]
public static extern bool GetUserObjectInformation(HandleRef hObj, int nIndex, [MarshalAs(UnmanagedType.LPStruct)] USEROBJECTFLAGS pvBuffer, int nLength, ref int lpnLengthNeeded);

dmex
vb.net syntax
<DllImport("user32.dll", SetLastError:=True)> Public Shared Function GetUserObjectInformation(ByVal hObj As HandleRef, ByVal nIndex As Integer, <MarshalAs(UnmanagedType.LPStruct)> ByVal pvBuffer As USEROBJECTFLAGS, ByVal nLength As Integer, ByRef lpnLengthNeeded As Integer) As Boolean
End Function