您的位置:首页 > 编程语言 > C#

【转帖】C# 获取系统启动项

2009-09-19 09:00 127 查看
此文转自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();
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: