S
ShaunO
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.
Thanks,
Shaun
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()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GetInstalledApps();
}
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();
listBox1.Items.Add(name);
}
}
}
}
}
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.
Thanks,
Shaun
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()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GetInstalledApps();
}
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();
listBox1.Items.Add(name);
}
}
}
}
}