以编程方式允许对注册表项的写访问 [英] Programmatically allow write access for a Registry key

查看:124
本文介绍了以编程方式允许对注册表项的写访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在产品安装期间,我需要以编程方式修改已知注册表项上的访问描述符。我希望它的工作方式是:

I need to programmatically modify the Access Descriptors on a known Registry key during product installation. The way I want it to work is:


  1. 安装程序以管理模式运行。


  2. 一个函数(我需要的)从该键查询ACL。

  3. 如果此函数发现组

  4. 如果没有,则应添加允许对用户群组进行写入访问的新权限。

  5. 为注册表项保存权限。

  1. The installer is run in Administrative mode.
  2. A Registry key is created.
  3. A function (the one I need) queries the ACL from the key.
  4. If this function finds that the group 'Users' already has write access, nothing should be done.
  5. If not, it should add a new permission allowing write access to the 'Users' group.
  6. The permissions are saved for the Registry key.

此问题类似于使用.NET设置注册表项写入权限 ,但是,我需要一个C ++ / Win32实现。

This question is similar to Setting Registry key write permissions using .NET, however, I need a C++/Win32 implementation.

提前感谢

推荐答案

您需要使用RegGetKeySecurity和RegSetKeySecurity的密钥的ACL。然后,您需要遍历ACE,检查适用于用户组SID的任何内容。然后你将修改/删除现有的和/或添加一个新的。请注意,在普通的Win32 C中使用ACL是一种痛苦。

For getting and setting the ACL of the key you need to use RegGetKeySecurity and RegSetKeySecurity. Then you need to iterate through the ACEs, examining any that apply to the "Users" group SID. Then you'll either modify/remove the existing one and/or add a new one. Be advised that working with ACLs in plain old Win32 C is a pain.

这篇关于以编程方式允许对注册表项的写访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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