AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

GetUserName

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

VB4-32,5,6
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

VB.NET
System.Security.Principal.WindowsIdentity.GetCurrent.Name

Operating Systems Supported
Requires Windows NT 3.1 or later; Requires Windows 95 or later

Library
Advapi32

Parameter Information
· 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 Values
If the function succeeds, the return value is nonzero, 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 zero. To get extended error information, call GetLastError.

Examples

Related Functions

VB.NET Example

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/