GetUserName

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

I am using VB.NET and need to get the user's name that
has logged onto the user's computer. In VB6 I used an
API call. Is this still the most efficint way or does
the .NET framework have an easier, more efficint way of
getting the user's name?

Many Thanks,
 
Robert said:
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)
 
Robert,
Is this still the most efficint way or does
the .NET framework have an easier, more efficint way of
getting the user's name?

System.Environment.UserName



Mattias
 
* "Robert said:
I am using VB.NET and need to get the user's name that
has logged onto the user's computer. In VB6 I used an
API call. Is this still the most efficint way or does
the .NET framework have an easier, more efficint way of
getting the user's name?

'Environment.UserName'.
 
I am using VB.NET and need to get the user's name that
has logged onto the user's computer. In VB6 I used an
API call. Is this still the most efficint way or does
the .NET framework have an easier, more efficint way of
getting the user's name?

Many Thanks,

System.Environment.UserName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

GetUserName 2
Getting the OS version` 4
VB.net and graphics 3
Using API function in VB.NET 3
Identify a change in computers 18
Working with Graphics in VB.NET???? 2
Enumerate Windows 3
Calling API 4

Back
Top