Vista Registry access doesnt work on x86 build

Posted on 2009-04-20
Last Modified: 2013-11-26
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

Question by:sdom100
    1 Comment
    LVL 41

    Accepted Solution

    What you're seeing is related to "Registry Virtualization" in Vista x64.
    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.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now