1

のレジストリのアンインストール エントリにキーを作成しようとしていますHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstallが、コードを実行すると、代わりに にキーが作成されHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wow6432Node\Microsoft\Windows\CurrentVersionます。このパスがどこから取得されているのかわかりません。

以下は私が使用しているコードです

private void addToRegistry(string installPath)
{
    using (RegistryKey parent = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true))
    {
        if (parent == null)
        {
            MessageBox.Show("Failed to open registry key. Installation cannot continue", "Registry Error", 
                MessageBoxButton.OK, MessageBoxImage.Error);
        }
        try
        {
            RegistryKey key = null;
            string appParent = "Boardies Email Server";
            parent.CreateSubKey(appParent);
            key = parent.OpenSubKey(appParent);
            //key = parent.OpenSubKey(appParent, true) ??
            //    parent.CreateSubKey(appParent);
            if (key == null)
            {
                MessageBox.Show("Failed to add registry entry. Error: nInstallation Aborted", "Registry Error", 
                    MessageBoxButton.OK, MessageBoxImage.Error);
                throw new Exception();
            }

            Assembly asm = GetType().Assembly;
            Version version = asm.GetName().Version;
            string exe = string.Format("{0}\\EmailServer.exe", installPath);

        }
        catch (Exception ex)
        {
            MessageBox.Show(string.Format("Failed to install, unable to insert into registry: {0}\n\nInstallation Aborted", ex.Message),
                "Registry Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }

ご協力いただきありがとうございます。

4

3 に答える 3

1

おそらく、アプリケーションは32ビットであり、Windows x64ではレジスタが仮想化されているため、32ビットと64ビットのアプリが共存して同じレジスタキーを使用できます。したがって、アプリはそれがこのパスに書き込んでいることを確認します。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

しかし、実際にはこの道を書いています:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wow6432Node\Microsoft\Windows\CurrentVersion

したがって、理論的には、別の32ビットアプリからそのようなキーが必要な場合、このパスもとして表示されるため、問題は発生しないはずです。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
于 2012-08-06T18:58:16.720 に答える
0

レジストリ リダイレクターです。

RegistryKey.OpenBaseKey MethodのRegistryView列挙を使用してみてください。RegistryView.Registry64 列挙メンバーを参照してください。

ところで、プログラムを 64 ビット プロセスとして実行できるようにすると、リダイレクトがなくなります: Project => Properties => Build タブ: Platform target をAnyCPUに変更します。

于 2012-08-06T18:53:29.573 に答える
0

これは、正しいトップ レベルで値を変更する必要があるためです。autoruns.exeで正しい場所を特定できます。それはあなたを正しい場所に導きます!

(Windows の起動時にファイル システム チェックを無効にした以下の例を参照してください)

ここに画像の説明を入力

このツールは、すべてのスタートアップ レジストリ キーだけでなく、サード パーティのインストールを含む他のすべてのサービスも検索します。

于 2012-08-06T23:25:22.170 に答える