尝试使用.net 2.0创建启动管理器

发布于 2024-10-08 06:20:25 字数 1255 浏览 0 评论 0原文

好的,我正在开发一个带有复选框的集成启动管理器,到目前为止,这就是我所拥有的,它在表单加载时执行此操作:

RegistryKey hklm = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
foreach (string Programs in hklm.GetValueNames())
{
    string GetValue = hklm.GetValue(Programs).ToString();
    ListViewItem item1 = listView1.Items.Add(Programs);
    item1.SubItems.Add(hklm.Name.ToString().Replace("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion", "HKLM"));
    item1.SubItems.Add(GetValue);
}

RegistryKey hkcu = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
foreach (string Programs in hkcu.GetValueNames())
{
    string GetValue = hkcu.GetValue(Programs).ToString();
    ListViewItem item2 = listView1.Items.Add(Programs);
    item2.SubItems.Add(hkcu.Name.ToString().Replace("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion", "HKCU"));
    item2.SubItems.Add(GetValue);
}  

我知道它可能有点草率,但它似乎有效。现在我想知道的是,如果我在列表视图中启用了复选框...我怎样才能拥有它:

A:检查“启用”的复选框/不检查“禁用”的复选框 B:当您选中一项时它会“启用”它,或者取消选中一项时它会“禁用”它吗?

或者!

(首选)创建一个上下文菜单(右键单击菜单)来禁用和重新启用每个条目(禁用它意味着创建一个名为“禁用开始”之类的子键,它将把键移至该位置,启用它们会将它们移回进入上一个密钥)

我知道要启用/禁用,您可以将密钥移动到不同的子项以安全保存,对吗?还是我这一切都错了?

OK so I'm working on a integrated start-up manager with check boxes, so far this is what i have, it does this on form load:

RegistryKey hklm = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
foreach (string Programs in hklm.GetValueNames())
{
    string GetValue = hklm.GetValue(Programs).ToString();
    ListViewItem item1 = listView1.Items.Add(Programs);
    item1.SubItems.Add(hklm.Name.ToString().Replace("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion", "HKLM"));
    item1.SubItems.Add(GetValue);
}

RegistryKey hkcu = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
foreach (string Programs in hkcu.GetValueNames())
{
    string GetValue = hkcu.GetValue(Programs).ToString();
    ListViewItem item2 = listView1.Items.Add(Programs);
    item2.SubItems.Add(hkcu.Name.ToString().Replace("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion", "HKCU"));
    item2.SubItems.Add(GetValue);
}  

i know its probably a bit sloppy but it seems to work. now what id like to know is, if i have check boxes enabled in the list view... how can i have it:

A: Check the ones that are "enabled"/not check the ones that are "Disabled"
B: make it so when you check one it "enables" it or uncheck one it "disables" it?

OR!

(preferred) make a context menu (right click menu) for disabling and re-enabling each entry (and disabling it would mean making a sub key called something like "Disabled Start" that it would move keys to and enabling them would move them back into the previous key)

i know for enabling/disabling you can just move the key to a different subkey for safe keeping, correct? or do i have this all wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朦胧时间 2024-10-15 06:20:25

我同意你的看法 。如果我是你,我会这样做。 :)

我认为您可以将这些禁用的密钥存储到应用程序目录中存储的文件中。你知道,比如 ini 文件。或者您可以使用自己创建的密钥将它们存储在注册表中。因此您可以在卸载管理器时删除它们。

I agree with you . and i world do this if i were you . :)

I think you can either store those disabled keys to a file stored in your app directory. you know , sth like ini file. or you can store them in the registry with a key created by yourself. so you can delete them when uninstalling the manager.

草莓酥 2024-10-15 06:20:25

那么,推荐的过程实际上是将这些条目保存到文本文件中。我强烈建议您使用隔离存储 如果你要为网络构建这个,那就更强大了。

我对此不太了解,但我认为您也可以将条目导出到文件中(也可以是IsolatedStorageFiles) 就像这个 家伙似乎已经完成(查找“ExportKey”方法),然后重新导入它们。请注意,在这种情况下,您仍然需要某种机制来记住条目,以便可以在列表视图中显示它们。

关于上下文菜单,我认为 可能是你想要什么,但我实际上只是用谷歌搜索并运行 Ubuntu,所以我之前无法真正尝试一下。

Well the recommended procedure would be so actually save those entries into text files. I storngly suggest that you use Isolated Storage and even stronger if you are going to be building this for a network.

I dunno much about this but I think you could also export the entries into files (which could also be IsolatedStorageFiles) just like this guy seems to have done (look for the "ExportKey" method) and then re-import them. Note that in this case you would still need to have some sort of mechanism to remember the entries so you can show them in the list view.

Regarding the context menu I think this might be what you want, but I just actually google it and running Ubuntu so I can't really try it out before.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文