Windows 7: How can I get a list of all Windows user names in .Net?

南楼画角 提交于 2019-12-12 12:29:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!