First, make sure that the computer has been installed with Xunlei. Open VS. NET and click the menu: Project> Add reference> COM> Add a reference to the ThunderAgent 1.0 Type Library.
1. Create a record call object
Private ThunderEng As New THUNDERAGENTLib. the Agent creates the thunder call object ThunderEng. addTask ("", "save another file name", "Save directory", "task comment", "reference address", "Start mode", "Download from original address only ", "Number of threads downloaded from the original address") 'Add a download task
ThunderEng. CommitTasks () 'submit the download task
2. Use Xunlei to call objects to query download task information
SFileSize = ThunderEng. GetTaskInfo (txtURL. Text, "FileSize") 'to get the downloaded file size
SDownedSize = ThunderEng. GetTaskInfo (txtURL. Text, "CompletedSize") 'to get the completed size
SFileName = ThunderEng. GetTaskInfo (txtURL. Text, "FileName") 'get the file name
Ii. Definition of interfaces of the thunder Platform
Obtain information
1. BSTR GetInfo (BSTR pInfoName)
Function: obtain information about thunder or platform.
Parameters:
Parameter Name Description
PInfoName information names, which can be found in the following four types:
◆ "ThunderExists": Does thunder exist?
◆ "ThunderRunning": whether or not thunder runs
◆ "ThunderVersion": the thunder version number
◆ "PlatformVersion": Platform version number
Return Value: The returned value is a string that corresponds to the pInfoName parameter.
Parameter Return Value
"ThunderExists" "true" and "false" do not exist
"ThunderRunning" and "true" are running, and "false" is not running.
"ThunderVersion": the version number "x. x"
"PlatformVersion" platform version "x. x"
2. HRESULT GetInfoStruct (INT pInfo)
Function: obtain all information related to thunder or platform.
Parameters:
Parameter Name Description
PInfo is actually a structure pointer of the THUNDER_INFO type. It is converted to the INT type before calling. After calling, the structure will fill in the platform information, which is defined as follows: China Network Management Alliance www, bitsCN, com
Typedef struct _ THUNDER_INFO
{
BOOL bThunderExists;
BOOL bThunderRunning;
CHAR szThunderVersion [32];
CHAR szPlatformVersion [32];
} THUNDER_INFO;
After the function is called, the corresponding information is filled in the structure.
Return Value:
0: obtained successfully.
Failed to get non-0
Task operations
3. Add a task
HRESULT AddTask
(BSTR pURL,
BSTR pFileName = "",
BSTR pPath = "",
BSTR pComments = "",
BSTR pReferURL = "",
INT nStartMode =-1,
INT nOnlyFromOrigin = 0,
INT nOriginThreadCount =-1 );
Function:
Add download task information to the platform,
This is not yet reflected in thunder
Parameters:
Parameter Name Description
PURL target URL, required Parameter
PFileName another storage name. The default value is null, indicating that it is processed by thunder. Optional Parameter
PPath storage directory. The default value is null, indicating that the directory is processed by thunder. Optional Parameter
PComments download comments. The default value is null. Optional.
PReferURL reference page URL. The default value is null. Optional.
NStartMode start mode. The value 0 starts manually. The value 1 starts immediately. The default value is-1, indicating that it is processed by thunder. An optional parameter.
Whether nOnlyFromOrigin can be downloaded only from the original URL, 1 can be downloaded only from the original URL, and 0 can be downloaded from multiple resources. The default value is 0. Optional Parameter
Number of threads downloaded from the original nOriginThreadCount address. The value ranges from 1 to 10. The default value is-1, indicating that the thread is processed by thunder. Optional Parameter
4. Start the task
HRESULT CommitTaskss ()
Function:
Submit the information of the AddTask download task to thunder for download and delete it from the platform.
Note: If the task added by AddTask is not submitted and canceled (CancelTasks is called), the Agent object is blocked during analysis, therefore, the caller should not leave any unsubmitted or canceled tasks to prevent the script executor from stopping the response.
5. Cancel the task
HRESULT CancelTasks ()
Function:
Cancel all download task information added by AddTask on the platform
6. Query Task Information
BSTR GetTaskInfo (BSTR pURL, BSTR pInfoName );
Parameters:
Parameter Name Description
PURL: the download URL to be queried.
PInfoName status names:
◆ "Exists": whether pURL is in the thunder task list
◆ "Path": storage directory
◆ "FileName": File Name
◆ "FileSize": File Size
◆ "CompletedSize": downloaded size
◆ "Percent": download progress
◆ "Status": Task Status