There are several ways to get this list, like WMI (windows media instrumentation).
But here I will use a different way, let's read the registry and list the win user list.
string users_reg_key=With using this registry key, we can have all users who login into that os. Let's write a simple function to read this registry key in C#.
@"SOFTWAREMicrosoftWindowsCurrentVersionExplorerDocFolderPaths";
public string[] ListWinUsersList()And now we get a string array filled with windows users list.
{
//The registry key for reading user list.
RegistryKey key =
Registry.LocalMachine.OpenSubKey(users_reg_key, true);
string[] winusers;
if (key != null && key.ValueCount > 0)
{
winusers = key.GetValueNames();
}
return winusers[];
}
1 comment:
I'm pretty sure this key only contains paths for the current user, not ALL users. SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList comes close, but not if the username has been changed post account creation.
Post a Comment