从HKEY_USER位置获取注册表路径 [英] Get the registry path from HKEY_USER location

查看:153
本文介绍了从HKEY_USER位置获取注册表路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我正在开发一个Windows应用程序.

我正在尝试在以下位置的注册表中写入值

HKEY_USER \\ S-1-5-21-2000478354-1214440339-682003330-1003 \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall



在我的系统中,我完全知道此路径


但是我想在客户端系统中运行我的应用程序时读取此值

从上面的路径,我想知道如何获得以下值

(S-1-5-21-2000478354-1214440339-682003330)在每个系统中.

如果我得到此命令,那么它将对我完全使用


谢谢您

Hi Friends i am developing one windows application .

i am trying to write value in registry in following location

HKEY_USER\\S-1-5-21-2000478354-1214440339-682003330-1003\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall



in my system i know this path exactly


but i want to read this value while my application running in client system

from the above path i want to know how to get this following value

(S-1-5-21-2000478354-1214440339-682003330) in every system .

if i get command for this then it will be use full for me


thanking you

推荐答案

写道:​​

从上面的路径我想知道如何获得以下值
(S-1-5-21-2000478354-1214440339-682003330)

from the above path i want to know how to get this following value
(S-1-5-21-2000478354-1214440339-682003330)


此值称为SID. SID是唯一的用户标识符.这样一来,即使您更改用户名,Windows仍然知道您是谁. :)

要获取当前登录用户的SID,您可以尝试:


This value is called SID. SID is a unique user identifier. This is so windows still knows who you are even if you change your username. :)

To get the SID of the currently logged user you could try:

string username = String.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName);
System.Security.Principal.WindowsIdentity id = new System.Security.Principal.WindowsIdentity(username);
string sid = id.User.AccountDomainSid.ToString();



或:



or:

System.Security.Principal.WindowsIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();
string sid = id.User.AccountDomainSid.ToString();



我希望这有帮助. :)
问候



I hope this helps. :)
Regards


没有用于搜索我所知道的注册表的命令.为什么需要更改值?
There are no commands for searching the registry that I know of. Why does the value you need change ?


为什么不使用硬编码的SID,而是不使用
Instead of using a hardcoded SID, why don''t you use the Registry.CurrentUser[^] field to access the subkeys? This would provide a portable solution, which is what I assume you''re going for.


这篇关于从HKEY_USER位置获取注册表路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆