xxhaishixx
发表于 2017-8-22 01:10:14
很不错,支持!这是DLL文件的源码。
#pragma once
// 所有结构体定义按1字节对齐
#pragma pack(push, 1)
struct DownTaskParam
{
DownTaskParam()
{
memset(this, 0, sizeof(DownTaskParam));
nReserved1 = 5;
bReserved = FALSE;
DisableAutoRename = FALSE;
IsOnlyOriginal = FALSE;
IsResume = TRUE;
}
int nReserved;
wchar_t szTaskUrl; // 任务URL
wchar_t szRefUrl; // 引用页
wchar_t szCookies; // 浏览器cookie
wchar_t szFilename; // 下载保存文件名.
wchar_t szReserved0;
wchar_t szSavePath; // 文件保存目录
HWNDhReserved;
BOOL bReserved;
wchar_t szReserved1;
wchar_t szReserved2;
BOOL IsOnlyOriginal; // 是否只从原始地址下载
UINT nReserved1;
BOOL DisableAutoRename; // 禁止智能命名
BOOL IsResume; // 是否用续传
DWORD reserved;
};
enumDOWN_TASK_STATUS
{
NOITEM = 0,
TSC_ERROR,
TSC_PAUSE,
TSC_DOWNLOAD,
TSC_COMPLETE,
TSC_STARTPENDING,
TSC_STOPPENDING
};
enum TASK_ERROR_TYPE
{
TASK_ERROR_UNKNOWN = 0x00, // 未知错误
TASK_ERROR_DISK_CREATE = 0x01, // 创建文件失败
TASK_ERROR_DISK_WRITE = 0x02, // 写文件失败
TASK_ERROR_DISK_READ = 0x03, // 读文件失败
TASK_ERROR_DISK_RENAME = 0x04, // 重命名失败
TASK_ERROR_DISK_PIECEHASH = 0x05, // 文件片校验失败
TASK_ERROR_DISK_FILEHASH = 0x06, // 文件全文校验失败
TASK_ERROR_DISK_DELETE = 0x07, // 删除文件失败失败
TASK_ERROR_DOWN_INVALID = 0x10, // 无效的DOWN地址
TASK_ERROR_PROXY_AUTH_TYPE_UNKOWN = 0x20, // 代理类型未知
TASK_ERROR_PROXY_AUTH_TYPE_FAILED = 0x21, // 代理认证失败
TASK_ERROR_HTTPMGR_NOT_IP = 0x30, // http下载中无ip可用
TASK_ERROR_TIMEOUT = 0x40, // 任务超时
TASK_ERROR_CANCEL = 0x41, // 任务取消
TASK_ERROR_TP_CRASHED= 0x42, // MINITP崩溃
TASK_ERROR_ID_INVALID = 0x43, // TaskId 非法
};
struct DownTaskInfo
{
DownTaskInfo()
{
memset(this, 0, sizeof(DownTaskInfo));
stat = TSC_PAUSE;
fail_code = TASK_ERROR_UNKNOWN;
fPercent = 0;
bIsOriginUsable = false;
fHashPercent = 0;
}
DOWN_TASK_STATUS stat;
TASK_ERROR_TYPE fail_code;
wchar_t szFilename;
wchar_t szReserved0;
__int64 nTotalSize; // 该任务总大小(字节)
__int64 nTotalDownload; // 下载有效字节数(可能存在回退的情况)
float fPercent; // 下载进度
int nReserved0;
int nSrcTotal; // 总资源数
int nSrcUsing; // 可用资源数
int nReserved1;
int nReserved2;
int nReserved3;
int nReserved4;
__int64 nReserved5;
__int64 nDonationP2P; // p2p贡献字节数
__int64 nReserved6;
__int64 nDonationOrgin; // 原始资源共享字节数
__int64 nDonationP2S; // 镜像资源共享字节数
__int64 nReserved7;
__int64 nReserved8;
int nSpeed; // 即时速度(字节/秒)
int nSpeedP2S; // 即时速度(字节/秒)
int nSpeedP2P; // 即时速度(字节/秒)
bool bIsOriginUsable; // 原始资源是否有效
float fHashPercent; // 现不提供该值
int IsCreatingFile; // 是否正在创建文件
DWORD reserved;
};
enum DOWN_PROXY_TYPE
{
PROXY_TYPE_IE = 0,
PROXY_TYPE_HTTP= 1,
PROXY_TYPE_SOCK4 = 2,
PROXY_TYPE_SOCK5 = 3,
PROXY_TYPE_FTP = 4,
PROXY_TYPE_UNKOWN= 255,
};
enum DOWN_PROXY_AUTH_TYPE
{
PROXY_AUTH_NONE =0,
PROXY_AUTH_AUTO,
PROXY_AUTH_BASE64,
PROXY_AUTH_NTLM,
PROXY_AUTH_DEGEST,
PROXY_AUTH_UNKOWN,
};
struct DOWN_PROXY_INFO
{
BOOL bIEProxy;
BOOL bProxy;
DOWN_PROXY_TYPE stPType;
DOWN_PROXY_AUTH_TYPE stAType;
wchar_t szHost;
INT32 nPort;
wchar_t szUser;
wchar_t szPwd;
wchar_t szDomain;
};
#pragma pack(pop)
namespace DownEngine
{
extern "C" __declspec(dllimport) BOOL XL_Init(void);
extern "C" __declspec(dllimport) BOOL XL_UnInit(void);
extern "C" __declspec(dllimport) HANDLE XL_CreateTask(DownTaskParam &stParam);
extern "C" __declspec(dllimport) BOOL XL_DeleteTask(HANDLE hTask);
extern "C" __declspec(dllimport) BOOL XL_StartTask(HANDLE hTask);
extern "C" __declspec(dllimport) BOOL XL_StopTask(HANDLE hTask);
extern "C" __declspec(dllimport) BOOL XL_ForceStopTask(HANDLE hTask);
extern "C" __declspec(dllimport) BOOL XL_QueryTaskInfo(HANDLE hTask, DownTaskInfo & stTaskInfo); //旧版接口,使用Ex接口替换
extern "C" __declspec(dllimport) BOOL XL_QueryTaskInfoEx(HANDLE hTask, DownTaskInfo & stTaskInfo);
extern "C" __declspec(dllimport) BOOL XL_DelTempFile(DownTaskParam &stParam);
extern "C" __declspec(dllimport) void XL_SetSpeedLimit(INT32 nKBps);
extern "C" __declspec(dllimport) void XL_SetUploadSpeedLimit(INT32 nTcpKBps,INT32 nOtherKBps);
extern "C" __declspec(dllimport) BOOL XL_SetProxy(DOWN_PROXY_INFO &stProxyInfo);
extern "C" __declspec(dllimport) void XL_SetUserAgent(const wchar_t *pszUserAgent);
extern "C" __declspec(dllimport) BOOL XL_ParseThunderPrivateUrl(const wchar_t *pszThunderUrl, wchar_t *normalUrlBuffer, INT32 bufferLen);
extern "C" __declspec(dllimport) BOOL XL_SetAdditionInfo( HANDLE task_id, WSAPROTOCOL_INFOW *sock_info, CHAR *http_resp_buf, LONG buf_len ); // WSAPROTOCOL_INFOW定义在Winsock2.h
extern "C" __declspec(dllimport) HANDLE XL_CreateTaskByURL(const wchar_t *url, const wchar_t *path, const wchar_t *fileName, BOOL IsResume);
extern "C" __declspec(dllimport) LONG XL_CreateTaskByThunder(wchar_t *pszUrl, wchar_t *pszFileName, wchar_t *pszReferUrl, wchar_t *pszCharSet, wchar_t *pszCookie);
extern "C" __declspec(dllimport) LONG XL_CreateBTTaskByThunder(const wchar_t *pszPath);
};
run108
发表于 2017-9-5 22:23:09
好东西啊
疯狂海军
发表于 2017-10-30 12:14:41
学习了!真的很不错
学习电脑爱好者
发表于 2017-10-30 12:38:58
感谢楼主分享 ,辛苦了。
gqiuy
发表于 2017-11-4 16:54:10
谢谢O(∩_∩)O谢谢
yzydys
发表于 2017-11-4 17:00:42
下载学习一下,谢谢!
︶ㄣ时空丶之翼
发表于 2017-11-6 09:50:36
支持一下啊!!
鬼脸君
发表于 2018-1-12 00:56:44
这个是个什么
ksxx
发表于 2018-2-2 03:18:10
试试水,谢谢大拿分享。luuuuu
kgmn
发表于 2018-2-3 17:38:00
有用的,感谢分享