且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Windows注册表中查找登录用户?

更新时间:2023-12-02 09:11:34

它与注册表无关...

你能做的就是获取当前运行应用程序的用户的用户名...

使用 WindowsIdentity [ ^ ]:

  string  szUser = System.Security 。.Principal.WindowsIdentity.GetCurrent()名称; 

te>

您可以在Windows 7中找到当前登录的用户@ \\\ HKEY_CURRENT_USER \Volatile Environment \USERNAME。



请检查以下链接以获取更多详细信息

当前登录用户的注册表项 [ ^ ]


Hi,

am developing a windows store 8.1 app using C# and xaml.

In my app i want to find logged in user name from Windows Registry.

How can i get that from C# code?

Anybody please help me.

Regards,

Santhosh

It has nothing to do with the registry...
What you can do is get the username for the user currently running the application...
Use WindowsIdentity[^] for that:
string szUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;


You can find the current logged in user @\HKEY_CURRENT_USER\Volatile Environment\USERNAME in Windows 7.

Please check below link for additional details
Registry key for the currently logged in user[^]