如何在C中获取当前用户注册表 [英] How to get current user registry in c
本文介绍了如何在C中获取当前用户注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hai all,
我正在系统帐户中运行服务..
我可以阅读当前登录的用户注册表(HEKY_CURRENT_USER)
如何使用系统帐户上运行的服务读取当前登录的用户注册表?
hai all,
i am running the service in system account..
can i read the current logged in user registry(HEKY_CURRENT_USER)
how can i read the currently logged in user registry using the service running on the system account?
推荐答案
HKEY_CURRENT_USER
是指向,并在登录时在用户注册表空间中设置.我不确定该链接是否可用于在其他帐户下运行的服务.服务程序中的一小段附加代码应该很快就能告诉您.
HKEY_CURRENT_USER
is a link to one of the entries underHKEY_USERS
and is set in the user registry space at logon. I am not sure that that link is available to a service running under a different account. A simple piece of additional code in your service program should soon be able to tell you.
查看此站点 ^ ]
由于可能有多个用户登录,请使用WTSEnumerateSessions获取所有会话的列表,并从中排除会话0.接下来,使用WTSQueryUserToken获取用户的sid,并通过ConvertSidToStringSid将其格式化为字符串.
您应该会得到类似S-1-5-21-3853930826-1272693629-3426184057-501的名称.将其附加到HKEY_USERS \中,您将获得所需的密钥名称.
Since multiple users may have logged on ,use WTSEnumerateSessions to get a list of all the sessions and exclude session 0 from it.Next,use WTSQueryUserToken to obtain the user''s sid and format it into a string by ConvertSidToStringSid.
You should get something like S-1-5-21-3853930826-1272693629-3426184057-501.Appending it to HKEY_USERS\ and you will get the key name you want.
这篇关于如何在C中获取当前用户注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文