我必须每天做一个程序来备份我的IDM下载列表,因为有其他人在使用我的电脑,他们删除了我的下载列表。
IDM API只允许我将下载添加到IDM列表中,那么有没有什么库或其他方法可以使用C#备份我的IDM下载列表?
感谢你的帮助
发布于 2015-03-04 07:41:29
感谢@Setsu找到了解决方案。注册表中有一个包含所有URL的键。关键字是HKEY_CURRENT_USER\Software\DownloadManager,它包含关键字,这些关键字包含名为Url0的值。
例如,HKEY_CURRENT_USER\Software\DownloadManager\85\Url0包含一个添加到IDM下载列表的链接。
因此,我在所有HKEY_CURRENT_USER\Software\DownloadManager子键中搜索Url0,并使用以下代码将值保存到列表框中:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace IDMListSaver
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\DownloadManager");
string[] keys = key.GetSubKeyNames();
for (int i = 0; i <= key.SubKeyCount-1; i++)
{
key = key.OpenSubKey(keys[i]);
Object o = key.GetValue("Url0");
if (o != null)
{
listBox1.Items.Add(o);
}
key = Registry.CurrentUser.OpenSubKey("Software\\DownloadManager");
}
}
}
}它当然可以变得更好,但它解决了我的问题,直到现在。
再次感谢@Setsu
https://stackoverflow.com/questions/28842530
复制相似问题