Windows自动启动程序问题

feilong215 2007-02-03 03:32:01
我想获得一份当前机器所有自启动程序的列表,希望可以和"msconfig"执行的System Configuration Utility中的Startup一致。

我现在遇到几个问题:
1. 我得到开始菜单中对应的路径的启动目录,里面是后缀为.lnk的快捷方式,我如何通过快捷方式得到该文件的属性信息
2. 在开始菜单对应的路径下(Documents and Settings),有“All Users.WINDOWS”和“All Users”路径,我应该取哪个,两个区别是什么?如何去区分
3. 从注册表Run下面读取的自启动信息,软件的Name如何得到,得到的是哪个内容?

希望能得到解决方法或是一些想法。

提供解决方法后,在开贴散分(可用分多)。
...全文
274 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sqllong 2007-07-30
  • 打赏
  • 举报
回复
mark
rgwfeng2 2007-07-08
  • 打赏
  • 举报
回复
good
dazhu2 2007-02-03
  • 打赏
  • 举报
回复
读取注册表
using Microsoft.Win32;
RegistryKey hklm=Registry.LocalMachine;
RegistryKey software=hklm.OpenSubKey("SOFTWARE");
RegistryKey microsoft=software.OpenSubKey("Microsoft");
RegistryKey win=microsoft.OpenSubKey("Windows");
RegistryKey cur=win.OpenSubKey("CurrentVersion");
RegistryKey run=cur.OpenSubKey("Run");
string[] a;
//获得名称存入数组
a=run.GetValueNames();
try
{
string[] s=new string[2];
ListViewItem b=new ListViewItem();

for(int i=0;i<run.ValueCount;i++)
{
s[0]=a[i];
s[1]=run.GetValue(s[0]).ToString();
b=new ListViewItem(s);
this.listView1.Items.Add(b); //添加数据到listview

}
hklm.Close();
}
王集鹄 2007-02-03
  • 打赏
  • 举报
回复
//开始菜单lnk文件读取
WshShell vWshShell = new WshShell();
string[] vFiles = Directory.GetFiles(
Environment.GetFolderPath(Environment.SpecialFolder.Startup));
foreach (string vFile in vFiles)
{

if (Path.GetExtension(vFile).ToLower() == ".lnk")
{
IWshShortcut shortcut = (IWshShortcut)vWshShell.CreateShortcut(vFile);
richTextBox1.AppendText(Path.GetFileName(shortcut.FullName) + "=" +
shortcut.TargetPath + "\r\n");
}
}
王集鹄 2007-02-03
  • 打赏
  • 举报
回复
//注册表读取
RegistryKey vRegistryKey = Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\Run");
string[] ValueNames = vRegistryKey.GetValueNames();
foreach (string vValueName in ValueNames)
{
richTextBox1.AppendText(string.Format("{0}={1}\r\n",
vValueName, vRegistryKey.GetValue(vValueName)));
}
vRegistryKey = Registry.LocalMachine.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\Run");
ValueNames = vRegistryKey.GetValueNames();
foreach (string vValueName in ValueNames)
{
richTextBox1.AppendText(string.Format("{0}={1}\r\n",
vValueName, vRegistryKey.GetValue(vValueName)));
}
zsuswy 2007-02-03
  • 打赏
  • 举报
回复
路过 ……
rocy520 2007-02-03
  • 打赏
  • 举报
回复
顶一下吧``学习

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧