i want get all values in "Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" and put it in listbox
via c# .
i want get all values in "Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" and put it in listbox
via c# .
EDIT AGAIN FOR Windows Form
Here's a complete listing, assuming you have a ListBox with an id of "lbKeys":
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.UI;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU");
// Check to see if there were any subkeys
if (myKey.SubKeyCount > 0)
{
foreach (string subKey in myKey.GetSubKeyNames())
{
lbKeys.Items.Add(subKey);
}
}
}
}
There may not have been any subkeys for the key you were looking at - under the previous code I gave you, the foreach loop wouldn't do anything because there was nothing to loop through.
Use OpenSubKey to open up Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU, and then call GetSubKeyNames to get the names of the subkeys. Here is a good example for you.
I think putting them in a ListBox is fairly easy task.
RegistryKey keys Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU");
foreach (string subKeyName in keys.GetSubKeyNames())
{
using(RegistryKey tempKey = keys.OpenSubKey(subKeyName))
{
Console.WriteLine("\nThere are {0} values for {1}.",
tempKey.ValueCount.ToString(), tempKey.Name);
foreach(string valueName in tempKey.GetValueNames())
{
Console.WriteLine("{0,-8}: {1}", valueName,
tempKey.GetValue(valueName).ToString());
}
}
}