A | B | C |  D | E | F |  G | H | I |  J | K | L |  M | N | O |  P | Q | R |  S | T | U |  V | W | X |  Y | Z


The GetUserNameEx function retrieves the name of the user or other security principal associated with the calling thread. You can specify the format of the returned name.

Declare Function GetUserNameEx Lib "secur32.dll" Alias "GetUserNameExA" (ByVal NameFormat As EXTENDED_NAME_FORMAT, ByVal lpNameBuffer As String, ByRef nSize As Long) As Long


Operating Systems Supported
Requires Windows 2000 or later; Win9x/ME: Not supported


Parameter Information
- NameFormat
[in] Value from the EXTENDED_NAME_FORMAT enumeration type indicating the desired name format. This value cannot be NameUnknown.

- lpNameBuffer
[out] Pointer to a buffer that receives the name in the specified format.

- nSize
[in/out] On input, specifies the size, in TCHARs, of the lpNameBuffer buffer. On output, receives the size of the returned string, including the terminating null character.
If the lpNameBuffer buffer is too small, the function fails GetLastError returns ERROR_MORE_DATA. The nSize parameter receives the required buffer size.

Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the user name is not available in the specified format, the error is ERROR_NONE_MAPPED. If the domain controller is not available to perform the lookup, the error is ERROR_NO_SUCH_DOMAIN.

Last update: 07 April 2006