32位程序如何读取“实数”? 64位版本的注册表? [英] How can a 32-bit program read the "real" 64-bit version of the registry?

查看:92
本文介绍了32位程序如何读取“实数”? 64位版本的注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 OpenKeyReadOnly 阅读 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run ,并且 GetValueNames ,但它从 HKLM\SOFTWARE\ Wow6432Node \Microsoft\Windows\CurrentVersion\Run 返回值

I'm trying to read HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run with OpenKeyReadOnly, and GetValueNames, but it's returning values from HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run instead.

如何读取64位值,而不是重定向到32位密钥?

How can I read the 64-bit values instead of from a redirect to the 32-bit key?

该程序作为管理帐户运行。我还尝试了 RegOpenKeyEx RegEnumValue

The program was run as an administrative account. I also tried RegOpenKeyEx and RegEnumValue.

m使用Delphi 2010。

I'm using Delphi 2010.

推荐答案

,您必须使用 KEY_WOW64_64KEY 值,当使用 TRegistry 类。

you must use the KEY_WOW64_64KEY value when open the Registry with the TRegistry class.

from MSDN:

from MSDN :


KEY_WOW64_64KEY 表示在64位Windows上的
应用程序应b $ b在64位注册表视图上运行。
32位
Windows将忽略此标志。

KEY_WOW64_64KEY Indicates that an application on 64-bit Windows should operate on the 64-bit registry view. This flag is ignored by 32-bit Windows.

此标志必须使用
OR运算符与该表中
中用于查询或访问
注册表值的其他标志组合

This flag must be combined using the OR operator with the other flags in this table that either query or access registry values.

尝试此示例应用。

{$APPTYPE CONSOLE}

uses
  Windows,
  Classes,
  registry,
  SysUtils;


procedure ReadRegistry;
var
  Registry: TRegistry;
  List    : TStrings;
begin
  Registry := TRegistry.Create(KEY_WRITE OR KEY_WOW64_64KEY);
  //Registry := TRegistry.Create(KEY_READ OR KEY_WOW64_64KEY);
  List     := TStringList.Create;
  try
    Registry.RootKey := HKEY_LOCAL_MACHINE;
    if Registry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Run') then
    begin
       Registry.GetValueNames(List);
       Writeln(List.Text);
    end;
    Registry.CloseKey;
  finally
    Registry.Free;
    List.Free;
  end;
end;

begin
  try
   ReadRegistry();
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
  Readln;
end.

这篇关于32位程序如何读取“实数”? 64位版本的注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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