通过COM对象控制Xunlei实现远程下载
IE时代,迅雷下载会在IE中注册并加载COM控件ThunderAgent.dll
,使用Js调起对象ThunderAgent.Agent
实现添加下载任务。
- GetInfo 获取迅雷状态
- AddTask 添加任务
- CommitTaskss 开始任务
- CancelTasks 取消任务
- GetTaskInfoStruct 任务状态查询(进度等)
function AddLink(Url,Info,Location,strCID,strStatUrl,strCookie,strCharset) {
if (Url != "") {
if (Info == "") {
Info = "unknown";
}
try {
var ThunderAgent = new ActiveXObject("ThunderAgent.Agent");
} catch(e) {
ThunderAgent = new ActiveXObject(\"ThunderAgent.Agent64\");
}
try {
ThunderAgent.AddTask12(Url, "", "", Info, Location, strCharset, -1, 0, -1, strCookie, strCID, strStatUrl, 0, "rightup");
} catch(e) {
try {
ThunderAgent.AddTask5(Url, "", "", Info, Location, -1, 0, -1, strCookie, strCID, strStatUrl, 1, \"\", -1);
} catch(e) {
ThunderAgent.AddTask2(Url, "", "", Info, Location, -1, 0, -1, strCookie);
}
}
ThunderAgent.CommitTasks2(1);
}
}