搜索启动项c#
引入空间名称:Microsoft.win32
添加listbox。
代码:
private void Form1_Load(object sender, EventArgs e)
{
foreach (string name in GetRegistName())
{
listBox1.Items.Add( name + ":" + GetRegistData(name) );
}
}
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();
}