110,546
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Runtime.InteropServices;
public static class XL
{
[DllImport("xldl.dll", CharSet = CharSet.Unicode)]
public static extern bool XL_Init();
[DllImport("xldl.dll", CharSet = CharSet.Unicode)]
public static extern bool XL_UnInit();
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr XL_CreateTask([In()]DownTaskParam stParam);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_StartTask(IntPtr hTask);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_StopTask(IntPtr hTask);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern object XL_SetSpeedLimit(Int32 nKBps);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int XL_CreateTaskByThunder(string pszUrl, string pszFileName, string pszReferUrl, string pszCharSet, string pszCookie);
//LONG XL_CreateTaskByThunder(wchar_t *pszUrl, wchar_t *pszFileName, wchar_t *pszReferUrl, wchar_t *pszCharSet, wchar_t *pszCookie)
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern object XL_SetUploadSpeedLimit(Int32 nTcpKBps, Int32 nOtherKBps);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern object XL_SetProxy(DOWN_PROXY_INFO stProxyInfo);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern object XL_DelTempFile(DownTaskParam stParam);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_DeleteTask(IntPtr hTask);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_GetBtDataFileList(string szFilePath, string szSeedFileFullPath);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_SetUserAgent(string pszUserAgent);
[DllImport("xldl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool XL_GetFileSizeWithUrl(string lpURL, Int64 iFileSize);
[DllImportAttribute("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAsAttribute(UnmanagedType.Bool)]
public static extern bool XL_QueryTaskInfoEx(IntPtr hTask, [Out()]DownTaskInfo stTaskInfo);
[DllImportAttribute("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr XL_CreateBTTask(DownBTTaskParam stParam);
[DllImportAttribute("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
public static extern long XL_QueryBTFileInfo(IntPtr hTask, UIntPtr dwFileIndex, ulong ullFileSize, ulong ullCompleteSize, UIntPtr dwStatus);
[DllImportAttribute("xldl.dll", EntryPoint = "XL_QueryTaskInfoEx", CallingConvention = CallingConvention.Cdecl)]
public static extern long XL_QueryBTFileInfo(IntPtr hTask, BTTaskInfo pTaskInfo);
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public class DownTaskParam
{
public int nReserved;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 2084)]
public string szTaskUrl;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 2084)]
public string szRefUrl;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 4096)]
public string szCookies;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szFilename;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szReserved0;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szSavePath;
public IntPtr hReserved;
public int bReserved = 0;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 64)]
public string szReserved1;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 64)]
public string szReserved2;
public int IsOnlyOriginal = 0;
public uint nReserved1 = 5;
public int DisableAutoRename = 0;
public int IsResume = 1;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2048, ArraySubType = UnmanagedType.U4)]
public uint[] reserved;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct BTTaskInfo
{
///LONG->int
public int lTaskStatus;
///DWORD->unsigned int
public uint dwUsingResCount;
///DWORD->unsigned int
public uint dwSumResCount;
///ULONGLONG->unsigned __int64
public ulong ullRecvBytes;
///ULONGLONG->unsigned __int64
public ulong ullSendBytes;
///BOOL->int
[MarshalAsAttribute(UnmanagedType.Bool)]
public bool bFileCreated;
///DWORD->unsigned int
public uint dwSeedCount;
///DWORD->unsigned int
public uint dwConnectedBTPeerCount;
///DWORD->unsigned int
public uint dwAllBTPeerCount;
///DWORD->unsigned int
public uint dwHealthyGrade;
}
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class DownTaskInfo
{
public DOWN_TASK_STATUS stat;
public TASK_ERROR_TYPE fail_code;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szFilename;
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szReserved0;
public long nTotalSize;
public long nTotalDownload;
public float fPercent;
public int nReserved0;
public int nSrcTotal;
public int nSrcUsing;
public int nReserved1;
public int nReserved2;
public int nReserved3;
///int
public int nReserved4;
///__int64
public long nReserved5;
///__int64
public long nDonationP2P;
///__int64
public long nReserved6;
///__int64
public long nDonationOrgin;
///__int64
public long nDonationP2S;
///__int64
public long nReserved7;
///__int64
public long nReserved8;
///int
public int nSpeed;
///int
public int nSpeedP2S;
///int
public int nSpeedP2P;
///boolean
public bool bIsOriginUsable;
///float
public float fHashPercent;
///int
public int IsCreatingFile;
///DWORD[64]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 64, ArraySubType = UnmanagedType.U4)]
public uint[] reserved;
}
public enum DOWN_TASK_STATUS
{
///NOITEM -> 0
NOITEM = 0,
TSC_ERROR,
TSC_PAUSE,
TSC_DOWNLOAD,
TSC_COMPLETE,
TSC_STARTPENDING,
TSC_STOPPENDING
}
public enum TASK_ERROR_TYPE
{
///TASK_ERROR_UNKNOWN -> 0x00
TASK_ERROR_UNKNOWN = 0,
///TASK_ERROR_DISK_CREATE -> 0x01
TASK_ERROR_DISK_CREATE = 1,
///TASK_ERROR_DISK_WRITE -> 0x02
TASK_ERROR_DISK_WRITE = 2,
///TASK_ERROR_DISK_READ -> 0x03
TASK_ERROR_DISK_READ = 3,
///TASK_ERROR_DISK_RENAME -> 0x04
TASK_ERROR_DISK_RENAME = 4,
///TASK_ERROR_DISK_PIECEHASH -> 0x05
TASK_ERROR_DISK_PIECEHASH = 5,
///TASK_ERROR_DISK_FILEHASH -> 0x06
TASK_ERROR_DISK_FILEHASH = 6,
///TASK_ERROR_DISK_DELETE -> 0x07
TASK_ERROR_DISK_DELETE = 7,
///TASK_ERROR_DOWN_INVALID -> 0x10
TASK_ERROR_DOWN_INVALID = 16,
///TASK_ERROR_PROXY_AUTH_TYPE_UNKOWN -> 0x20
TASK_ERROR_PROXY_AUTH_TYPE_UNKOWN = 32,
///TASK_ERROR_PROXY_AUTH_TYPE_FAILED -> 0x21
TASK_ERROR_PROXY_AUTH_TYPE_FAILED = 33,
///TASK_ERROR_HTTPMGR_NOT_IP -> 0x30
TASK_ERROR_HTTPMGR_NOT_IP = 48,
///TASK_ERROR_TIMEOUT -> 0x40
TASK_ERROR_TIMEOUT = 64,
///TASK_ERROR_CANCEL -> 0x41
TASK_ERROR_CANCEL = 65,
///TASK_ERROR_TP_CRASHED -> 0x42
TASK_ERROR_TP_CRASHED = 66,
///TASK_ERROR_ID_INVALID -> 0x43
TASK_ERROR_ID_INVALID = 67
}
public enum DOWN_PROXY_TYPE
{
///PROXY_TYPE_IE -> 0
PROXY_TYPE_IE = 0,
///PROXY_TYPE_HTTP -> 1
PROXY_TYPE_HTTP = 1,
///PROXY_TYPE_SOCK4 -> 2
PROXY_TYPE_SOCK4 = 2,
///PROXY_TYPE_SOCK5 -> 3
PROXY_TYPE_SOCK5 = 3,
///PROXY_TYPE_FTP -> 4
PROXY_TYPE_FTP = 4,
///PROXY_TYPE_UNKOWN -> 255
PROXY_TYPE_UNKOWN = 255
}
public enum DOWN_PROXY_AUTH_TYPE
{
///PROXY_AUTH_NONE -> 0
PROXY_AUTH_NONE = 0,
PROXY_AUTH_AUTO,
PROXY_AUTH_BASE64,
PROXY_AUTH_NTLM,
PROXY_AUTH_DEGEST,
PROXY_AUTH_UNKOWN
}
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class DOWN_PROXY_INFO
{
///BOOL->int
[MarshalAsAttribute(UnmanagedType.Bool)]
public bool bIEProxy;
///BOOL->int
[MarshalAsAttribute(UnmanagedType.Bool)]
public bool bProxy;
///DOWN_PROXY_TYPE
public DOWN_PROXY_TYPE stPType;
///DOWN_PROXY_AUTH_TYPE
public DOWN_PROXY_AUTH_TYPE stAType;
///wchar_t[2048]
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 2048)]
public string szHost;
///INT32->int
public int nPort;
///wchar_t[50]
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 50)]
public string szUser;
///wchar_t[50]
[MarshalAsAttribut