Вы можете использовать реестр, который требует немного разбора, но эй, это работает. Вот некоторый код:
C #
RegistryKey userskey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList");
foreach (string keyname in userskey.GetSubKeyNames())
{
using (RegistryKey key = userskey.OpenSubKey(keyname))
{
string userpath = (string)key.GetValue("ProfileImagePath");
string username = System.IO.Path.GetFileNameWithoutExtension(userpath);
Console.WriteLine("{0}", username);
}
}
VB
Dim userskey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
For Each keyname As String In userskey.GetSubKeyNames()
Using key As RegistryKey = userskey.OpenSubKey(keyname)
Dim userpath As String = DirectCast(key.GetValue("ProfileImagePath"), String)
Dim username As String = System.IO.Path.GetFileNameWithoutExtension(userpath)
Console.WriteLine("{0}", username)
End Using
Next