[英]How can I find the InternetRegistry User Key or Parent Registry Key
I have a BHO which on the first run is gathering activation information and storing this in the registry. 我有一个BHO,它在第一次运行时正在收集激活信息并将其存储在注册表中。
(I think) due to IE's permission's I am only able to store this in the registry branch (我认为)由于IE的允许,我只能将其存储在注册表分支中
HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\InternetRegistry\\REGISTRY\\USER\\S-0-0-00-000000000-000000000-000000000-0000\\Software\\MyBHO\\MyKey HKEY_CURRENT_USER \\ Software \\ Microsoft \\ Internet Explorer \\ InternetRegistry \\ REGISTRY \\ USER \\ S-0-0-00-000000000-000000000-000000000-0000 \\ Software \\ MyBHO \\ MyKey
Where S-0-0-00-000000000-000000000-000000000-0000 is a unique key for each user. 其中S-0-0-00-000000000-000000000-000000000-0000是每个用户的唯一密钥。
Which is fine using RegCreateKey()
with "Software\\MyBHO\\MyKey"
. 将RegCreateKey()
与"Software\\MyBHO\\MyKey"
一起使用会很好。 It's all created and running lovely. 一切都已创建并且运行良好。 It determines where in space to store the Key with no problems. 它确定了在什么地方存储密钥没有问题。
The Problem: 问题:
When I carry out an uninstall I want to remove this key and as this is run outside of IE I have no way to determine where that key is / what the user string is. 当我执行卸载时,我想删除该密钥,并且由于它是在IE之外运行的,所以我无法确定该密钥在哪里/用户字符串是什么。
Options I have in mind: 我想到的选择:
Option 1 (Ideal) Find out this user string first to then build a new path for the key I wish to remove and remove it. 选项1 (理想)首先找到此用户字符串,然后为我希望删除的密钥建立一个新路径并删除它。 How? 怎么样?
Option 2 At the point of activation store the path to the key in another registry value that can be accessed. 选项2在激活时,将密钥的路径存储在另一个可以访问的注册表值中。 Then read, and delete both (Which seems a bit backwards and probably wont work due to the access restrictions of the BHO on the registry (Thus it being written there in the first place)) 然后读取并删除两者(这似乎有些倒退,可能由于BHO对注册表的访问限制而无法正常工作(因此,它首先被写入此处))
Do you know if there is any way to find this User key or even how to find the parent dir. 您是否知道有什么方法可以找到此用户密钥,甚至如何找到父目录。
Edit Upon continued research I've found that the thing I'm referring to as "user key" is the current Users "SID". 编辑经过不断的研究,我发现我所说的“用户密钥”是当前的用户“ SID”。 Maybe this will yield me better results. 也许这会给我带来更好的结果。
Call GetUserName
to get the user name, and LookupAccountName
to get his SID. 调用GetUserName
获取用户名,并调用LookupAccountName
获取他的SID。
ConvertSidToStringSid
is a useful utility function to format a SID as a S-1-5-32-00000000-00000000-00000000-00000000-0000
string ConvertSidToStringSid
是有用的实用程序函数,用于将SID格式化为S-1-5-32-00000000-00000000-00000000-00000000-0000
字符串
If you really want to write per-user data to the registry, use IEGetWriteableHKCU() . 如果您确实想将每个用户的数据写入注册表,请使用IEGetWriteableHKCU() 。
In general there is no good way to remove per-user data at uninstall. 通常,没有很好的方法在卸载时删除每个用户的数据。 For example, what if you install as user A and the uninstall as user B? 例如,如果您以用户A的身份进行安装并以用户B的身份进行卸载,该怎么办? Are you going to go find all of them and delete them? 您要去查找所有这些并将其删除吗? Just leave the turds behind. 只是丢下粪便。
Alternatively you could consider using a different data store. 或者,您可以考虑使用其他数据存储。 Do you really need the registry? 您真的需要注册表吗? Can you store this data in a file? 您可以将这些数据存储在文件中吗? What about Web Storage ? Web存储呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.