我必须每天制作一个程序来备份我的IDM下载列表,因为还有其他人在使用我的电脑并删除了我的下载列表。
IDM API只允许我添加下载到IDM列表,那么是否有任何库或其他方式使用C#备份我的IDM下载列表?
感谢您的帮助
答案 0 :(得分:0)
感谢@Setsu找到了解决方案。注册表中有一个包含所有URL的密钥。密钥是HKEY_CURRENT_USER\Software\DownloadManager
,它包含的密钥包含名为Url0
的值,其中包含URL。
作为示例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