Subject: Re: How to get the user name
From: [email-masked] ("Ben Constable")

31 Jan 1997 14:01:00 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Original-To: <[email-masked]>, <[email-masked]>
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
Original-Sender: [email-masked]

> How can I get the login-name under Win95 and Win-NT 4.0?

I assume you don't have the win32 SDK. If you did, you would probably go to
the index, and type "GetUserName" and find that you get this entry:

GetUserName  QuickInfo  Overview  Group

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,	// address of name buffer 
    LPDWORD  nSize 	// address of size of name buffer 
   );	

Parameters

lpBuffer

Points 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. 

nSize

Pointer to a DWORD that, on input, specifies the maximum size, in
characters, of the buffer specified by the lpBuffer parameter. If this
buffer is not large enough to contain the entire user name, the function
fails. If the function succeeds, it will place the number of characters
copied to the buffer into the DWORD that nSize points to. 

Return Value

If the function succeeds, the return value is TRUE, and the variable
pointed to by nSize contains the number of characters copied to the buffer
specified by lpBuffer, including the terminating null character. 
If the function fails, the return value is FALSE. To get extended error
information, call GetLastError. 

Remarks

If the current thread is impersonating another client, the GetUserName
function returns the user name of the client that the thread is
impersonating. 

See Also

LookupAccountName 

Ben Constable
[email-masked]

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".