平台目标x86和任何CPU

zee*_*zee 0 c# x86 adobe version anycpu

简单的代码我有小问题.此代码在"x86"模式下正常工作,但在"任何CPU"模式下无法正常工作,也许可以在"x86"上运行一个类,在"任何CPU"模式下运行另一个类?码:

namespace Software_Info_v1._0
{
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;

public class Adobe
{
    public string GetAdobeVersion()
    {
        try
        {
            RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe");
            if (adobe != null)
            {
                RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");
                if (acroRead != null)
                {
                    string[] acroReadVersions = acroRead.GetSubKeyNames();
                    foreach (string versionNumber in acroReadVersions)
                    {
                        Console.WriteLine("Acrobat Reader version: " + versionNumber);
                    }
                }
            }
        }
        catch
        {
        }
        return null;
    }
}
}
Run Code Online (Sandbox Code Playgroud)

ken*_*n2k 7

这是因为注册表重定向.

对于32位和64位操作系统,注册表的结构是不同的.

假设您在64位计算机上运行应用程序,编译x86目标会使您的程序使用WOW64模式(64位上的32位进程)运行,并且您正在读取Wow6432Node下的键.在C#中读取注册表时看到奇怪的行为