I want to get the e-mail address of the user that is currently logged on to Visual studio, in debug mode of course. Just like getting windows account name using Environment.UserName.
is that possible?
I want to get the e-mail address of the user that is currently logged on to Visual studio, in debug mode of course. Just like getting windows account name using Environment.UserName.
is that possible?
I would never use the VisualStudio username for a licensing system. The name of the user of VS is stored in a simple registry key and can be easily manipulated.
You can retrieve the username/account information for the most Visual Studio versions up to 14 (Visual Studio 2015) with the following code. Visual Studio 2017 has a different registry path. Read more about it here.
const byte minVSVersion=11; // Visual Studio 2012
const byte maxVSVersion=14; // Visual Studio 2015
static List<string> getVSUsers()
{
var vsUsrs=new List<string>();
for(byte version=minVSVersion; version<=maxVSVersion; version++)
vsUsrs.Add((string)Registry.GetValue(
@"HKEY_USERS\.DEFAULT\Software\Microsoft\VisualStudio\"+version+@".0_Config\Registration",
"UserName", null));
return vsUsrs.Where(usr => usr!=null).ToList();
}
Unfortunately, it is not possible to determine exactly which VisualStudio version the user used to compile the program.