如何获取当前登录用户?获取登录用户不是运行程序的用户C#,Windows
我已经尝试过
Environment.CurrentUser
和
WindowsIdentity.GetCurrent().
它们都返回正在运行PROGRAMM用户。
感谢您的帮助。
亲切的问候, 桑德罗
如何获取当前登录用户?获取登录用户不是运行程序的用户C#,Windows
我已经尝试过
Environment.CurrentUser
和
WindowsIdentity.GetCurrent().
它们都返回正在运行PROGRAMM用户。
感谢您的帮助。
亲切的问候, 桑德罗
添加指令System.Management
。
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
string username = (string)collection.Cast<ManagementBaseObject>().First()["UserName"];
或者退房this accepted answer。
我们需要了解更多关于您的设置,用户如何登录? –
Duplicate:http://stackoverflow.com/questions/11951745/how-to-get-currently-logged-on-user-name-and-account-typeadmin-nonadmin-when-t – greenhoorn
用户使用域名服务。 – sandrome