Click to See Complete Forum and Search --> : User Name from START menu? (not System.Environment.UserName)


MNovy
January 13th, 2009, 05:23 AM
Hi,

how can I obtain the name which is displayed on top of the Windows START menu?

Mike

dannystommen
January 13th, 2009, 06:31 AM
First add System.DirectoryServices as reference to your project, next use the next code

string servername = Environment.UserDomainName;
string username = Environment.UserName;

using (System.DirectoryServices.DirectoryEntry domain = new
System.DirectoryServices.DirectoryEntry(string.Format("WinNT://{0}/{1}", servername, username))) {
string fullName = domain.Properties["FullName"].Value.ToString() ;
}

MNovy
January 13th, 2009, 06:38 AM
Thx!