问题
Is there a simple way to get the names of all the user names of a local Windows 7 machine using .Net? So if I had a machine named MyPC, and it had 3 users MyPC\Mike, MyPC\Bob, and MyPC\Steve, I'd just want to be able to query to get Mike, Bob, and Steve. Of course, I don't care if they have the computer name attached, or not, as well.
回答1:
http://www.codeproject.com/KB/cs/enumerate_system_users.aspx
回答2:
If no-one comes up with a better way, you could enumerate the \Users folder and use the folders in there as representations. (Providing each user has logged in and the network isn't using roaming profiles)
来源:https://stackoverflow.com/questions/2299100/windows-7-how-can-i-get-a-list-of-all-windows-user-names-in-net