此文转自http://www.cnblogs.com/baaigeini/archive/2009/03/09/1407077.html
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 WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
foreach (string name in GetRegistName())
{
this.label1.Text += name + ":" + GetRegistData(name) + "/r/n";
}
}
private string GetRegistData(string name)
{
string registData;
RegistryKey hkml = Registry.LocalMachine;
RegistryKey aimdir = hkml.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Run", true);
registData = aimdir.GetValue(name).ToString();
return registData;
}
private string[] GetRegistName()
{
RegistryKey hkml = Registry.LocalMachine;
RegistryKey aimdir = hkml.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Run", true);
return aimdir.GetValueNames();
}
}
}