无法读取Win注册表-使用Delphi的Firebird密钥 [英] Failed to read win registry - firebird key using delphi

查看:84
本文介绍了无法读取Win注册表-使用Delphi的Firebird密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白.我想检查Firebird服务器的窗口注册表项是否存在.密钥存在,但函数返回false. 怎么了?我正在将Windows 7 64x与delphi 2010结合使用.

I do not understand. There is a window registry key of firebird server I want to check if it exists. The key exists but the function returns false. What is wrong? I'm using Windows 7 64x with delphi 2010.

谢谢. 戴维斯.

procedure x;
  var
    reg:TRegistry;
begin

  reg := TRegistry.Create;
  reg.RootKey := HKEY_LOCAL_MACHINE;

  if reg.OpenKey('\SOFTWARE\Firebird Project\Firebird Server\Instances',false)=true then
  begin
    ShowMessage('Key exists');
  end;

end;

推荐答案

最可能的原因是您已经打开了请求写访问权限的密钥,但是在Windows 7上的UAC下,默认情况下,用户没有对HKLM.通过将KEY_READ传递给TRegistry构造函数,或使用 OpenKeyReadOnly 即可解决此问题而不是OpenKey.

The most likely reason is that you have opened the key requesting write access but on Windows 7 under UAC, users do not, by default, have write access to HKLM. Solve this by passing KEY_READ to the TRegistry constructor, or by using OpenKeyReadOnly rather than OpenKey.

下一个最可能的解释是您已经安装了64位Firebird服务器.但是您的32位程序从32位注册表中读取内容,因此无法从64位Firebird中找到密钥.请参阅注册表重定向器,以了解有关这两个不同注册表的更多信息 views .有关详细信息,请参见访问备用注册表视图关于如何从32位进程中读取64位注册表的信息.转换为Delphi后,您需要在 Access 标志中包含KEY_WOW64_64KEY.同样,您可以将此标志传递给TRegistry构造函数,这可能会更方便.

The next most likely explanation is that you have the 64 bit Firebird server installed. But your 32 bit program reads from the 32 bit registry and so does not find the keys from the 64 bit Firebird. See Registry Redirector to learn more about the two different registry views. See Accessing an Alternate Registry View for details on how to read the 64 bit registry from a 32 bit process. Translated into Delp you would need to include KEY_WOW64_64KEY in the Access flags. Again, you can pass this flag to the TRegistry constructor which may be more convenient.

因此,总而言之,如果您正在寻找32位服务器,请像这样创建注册表对象

So, in summary, if you are looking for a 32 bit server, create the registry object like this

reg := TRegistry.Create(KEY_READ);

如果您的Firebird服务器为64位,请使用此

and if your Firebird server is 64 bit then use this

reg := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);

这篇关于无法读取Win注册表-使用Delphi的Firebird密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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