非管理员模式下的注册表访问 [英] Registry access in non-admin mode

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

问题描述

我在Delphi中编写了几个长期存在的应用程序,将其设置保存在注册表中。我使用HKEY_LOCAL_MACHINE硬设置,如配置首选项和HKEY_CURRENT_USER软信息,如窗口位置,MRU列表等。



现在我的用户告诉我认为,在非管理员(标准用户)模式下,应用程序不起作用。看,我看到当应用程序处于管理模式时,我无法读取放入HKEY_LOCAL_MACHINE的设置。



我有什么选择?我对标准模式知之甚少,这对于访问注册表的方式有何影响。任何信息赞赏。

解决方案

您可以从HKLM读取为非管理员用户;你不能写信。



在构建它时使用TRegistry.Create(KEY_READ),并将RootKey设置为HKLM。

  var 
注册表:TRegistry;
begin
注意:= TRegistry.Create(KEY_READ)
try
Reg.RootKey:= HKLM;
//读取值在这里
finally
Reg.Free;
结束
结束

打开特定注册表项时也可以使用TRegistry.OpenKeyReadOnly()这有助于非管理员访问注册表的区域。


I've several long-standing apps written in Delphi that persist their settings in the registry. I've used HKEY_LOCAL_MACHINE for 'hard' settings such as configuration preferences and HKEY_CURRENT_USER for 'soft' info such as window positions, MRU lists etc.

Now my users are telling me that in non-admin (standard user) mode the apps dont work. Looking, I see that I'm not able to read a setting put into HKEY_LOCAL_MACHINE when the app was in admin mode.

What are my options for this? I know little about standard mode and how this affects access to the registry at all. Any info appreciated.

解决方案

You can read from HKLM as a non-admin user; you just can't write to it.

Use TRegistry.Create(KEY_READ) when constructing it, and set the RootKey to HKLM.

var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create(KEY_READ)
  try
    Reg.RootKey := HKLM;
    // Read value here
  finally
    Reg.Free;
  end;
end;

You can also use TRegistry.OpenKeyReadOnly() when opening a specific registry key; this helps with non-admin access to areas of the registry as well.

这篇关于非管理员模式下的注册表访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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