"Robert" <ro********@triad.rr.com> wrote in message
news:06****************************@phx.gbl...
I am using VB.NET and need to get the user's name that
has logged onto the user's computer.
Public Function GetUserName() As String
GetUserName = (SystemInformation.UserName.ToString)
' This will return only the user name
End Function
' If you want the domain name included, use the code:
Imports System
Imports System.Security
Public Module SysInfo
Public Function GetUserName() As String
Principal.WindowsIdentity.GetCurrent.Name
' This will return 'domain\username'
End Function
End Module
or
' You can also call the code direct, such as Text1.Text =
(SystemInformation.UserName.ToString)