プラットフォームターゲットx86および任意のCPU
質問
単純なコードには小さな問題があります。このコードは「x86」モードで適切に動作していますが、「任意のCPU」モードではありませんが、「x86」で1つのクラスと「任意の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;
}
}
}
解決
これはそのせいです レジストリリダイレクト.
レジストリの構造は、32ビットと64ビットOSで異なります。
64ビットマシンでアプリケーションを実行していると仮定すると、x86ターゲットをコンパイルして、WOW64モード(64ビットで32ビットプロセス)を使用してプログラムを実行し、WOW6432Nodeの下でキーを読み取ります。見る c#でレジストリを読むときの奇妙な動作
他のヒント
所属していません StackOverflow