[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 603
  • Last Modified:

Vista Registry access doesnt work on x86 build

Note: VS2005, Vista 64

Hi, when i run the following code, it only works if i build it for "Any CPU" if i choose "x86" then the listbox is empty rather than full of application names read from the registry
Could someone please advise how to achieve this result with code that works under x86 build


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace WindowsApplication17
    public partial class Form1 : Form
        public Form1()
        private void Form1_Load(object sender, EventArgs e)
        public void GetInstalledApps()
            //string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            string software = "";
            string softwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products";
            using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(softwareKey, false))
                foreach (string skName in rk.GetSubKeyNames())
                    string name = Registry.LocalMachine.OpenSubKey(softwareKey, false).OpenSubKey(skName, false).OpenSubKey("InstallProperties", false).GetValue("DisplayName").ToString();

Open in new window

1 Solution
What you're seeing is related to "Registry Virtualization" in Vista x64.   http://msdn.microsoft.com/en-us/library/aa965884(VS.85).aspx
Unfortunately, the native Registry classes in the .Net Framework do not allow to "pick" a virtualized view of the registry.   So, when run as a 32-bit app, it only sees the 32-bit virtualized registry... likewise, when run as a 64-bit app, it only sees the 64-bit registry.
I've started a project that overcomes this limation on CodePlex...  it currently works for ReadOnly acccess, but could be easily expanded to add write capabilities.  http://registry64bit.codeplex.com/

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now