Windows User

Hi all...

Please could you tell me how i could get the username of a user logged on to a windows terminal? ie Guest?

Thanks in advance,
Stuart

Comments

  • : Hi all...
    :
    : Please could you tell me how i could get the username of a user logged on to a windows terminal? ie Guest?
    :
    : Thanks in advance,
    : Stuart
    :

    The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system.

    BOOL GetUserName(
    LPTSTR lpBuffer, // name buffer
    LPDWORD nSize // size of name buffer
    );

    Parameters
    lpBuffer
    [out] Pointer to the buffer to receive the null-terminated string containing the user's logon name. If this buffer is not large enough to contain the entire user name, the function fails. A buffer size of (UNLEN + 1) characters will hold the maximum length user name including the terminating null character. UNLEN is defined in Lmcons.h.
    nSize
    [in/out] On input, specifies the maximum size, in TCHARs, of the buffer specified by the lpBuffer parameter. On output, receives the number of characters copied to the buffer, including the terminating null character.
    If the buffer is too small, the function fails GetLastError returns ERROR_MORE_DATA. The nSize parameter receives the required buffer size.


    Good luck,
    Alexey
  • : Hi all...
    :
    : Please could you tell me how i could get the username of a user logged on to a windows terminal? ie Guest?
    :
    : Thanks in advance,
    : Stuart
    :
    Again the same question? You got your answer (in fact two ways) in a previous post.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories