Thunder API interface documentation - automatically download the call Thunder

We can use the open API interface provided by the Thunder to automatically download file detailed interface description we can see below.

Thunder is the first to explain the API interface is invoked .com

The first is the script, written a variety of different languages, and I write here with the vbs: 
copy the code code is as follows:
the Set ThunderAgent = CreateObject ( "ThunderAgent.Agent.1") 
Call ThunderAgent.AddTask ( "HTTP: //www.jb51 .net / files / bjhyn.mp3 "," Beijing welcomes you .mp3 "," c: \ A \ "," "," http://www.readlog.cn ", 1,0,5) 
Call ThunderAgent. CommitTasks2 (. 1) 

Call ThunderAgent.AddTask ( "http://file.fzone.cn/upload2/hompyFile/2007/28/921524670987.wma", "Lucky star .wma", "c: \ a \ b \ c \ "," ", HTTP: //www.jb51.net,1,0,5) 
Call ThunderAgent.CommitTasks2 (1) 
the Set ThunderAgent = Nothing 

then is to start the Thunder, go to tools - configuration - advanced, by the IE context menu "use Thunder download" add task in front of this option to remove the hook. 

Thunder remain open state, this time the implementation of the above script, you add tasks to confirm that the dialog box does not appear. 

Attachment: AddTask which uses this method, the parameters of this method are as follows: AddTask ( "Download", "Save file name", "




pFileName Save name, the default is empty, represented by Thunder processing, optional parameters 
pPath storage directory, the default is empty, represented by Thunder processing, optional parameters 
pComments download notes, the default is empty, optional parameter 
referring page URL pReferURL, by default empty, optional parameters 
nStartMode start mode, manual start 0, 1 start immediately, the default is -1, which is handled by the Thunder, optional parameters 
if nOnlyFromOrigin download only from the original URL, 1 download only from the original URL, 0 downloads many resources, the default is 0, the optional parameter 
nOriginThreadCount original URL download threads, range 1-10, default to -1 processed by Thunder, optional parameters 

Attachment: AddTask which uses this method, the parameters of this method are as follows:

AddTask ( "Download", "Save file name", "Save directory", "Task Notes", "reference address", "Start Mode", "download only from the original address", "download threads from the original address") . 

Parameter name Meaning 
pURL target URL, the parameters must 
pFileName Save name, the default is blank, handled by the Thunder, optional parameters 
pPath storage directory, the default is blank, handled by the Thunder, optional parameters 
pComments download notes, empty by default, can be selected parameters 
pReferURL reference page URL, the default is empty, optional parameters 
nStartMode start mode, manual start 0, 1 start immediately, the default is -1, which is handled by the Thunder, optional parameters 
if nOnlyFromOrigin download only from the original URL, from a the original URL download, download resources over 0, the default is 0, the optional parameter 
nOriginThreadCount original address download threads, the range of 1-10, the default is -1, which is handled by the Thunder, optional parameters

Public Function Thunder download (URL As String, Optional save path As String, Optional saved as a file name As String, Optional download Comment As String, Optional reference pages As String, Optional start mode As Long = 1, Optional No download only from the original URL as Boolean = False, optional address to download the original number of threads. 5 = Long aS) aS Boolean
the On the GoTo the Err Error
Dim ThunderAgent
'nStartMode start mode, manual start 0, 1 immediately, the default to -1 processed by Thunder, optional parameters
'nOnlyFromOrigin only downloads from the original URL, 1 from the original download only the URL, download many resources 0, the default is 0, the optional parameter
' nOriginThreadCount original URL download threads, range 1-10, default to -1 processed by Thunder optional parameters
the Set ThunderAgent = CreateObject ( "ThunderAgent.Agent.1")
the If ThunderAgent Nothing is is the Then GoTo Err
Call ThunderAgent.AddTask (URL saved as a file name, saving path, download notes, referring page, start mode, otherwise only Download from the original URL, the original address download threads)
Call ThunderAgent.CommitTasks2 (1)
the Set Thu nderAgent = Nothing
Thunder download = True
Function Exit
Err:
Thunder download False =
End Function


Call 迅雷下载("http://www.baidu.com/index.html", "c:\", "index.html", "http://www.baidu.com")

First, make sure the computer has been installed Thunder, open the VS.NET click on the menu: Project -> Add Reference -> COM-> Add to ThunderAgent 1.0

Type Library reference 
  1. Create Thunder calling object

Private ThunderEng As New THUNDERAGENTLib.Agent 'call object creation Thunder

ThunderEng.AddTask ( "Download", "Save file name", "Save directory", "Task Notes", "reference address", "Start mode", "

Download only from the original address "," address from the original number of download threads ") 'Add download task

ThunderEng.CommitTasks () 'submit download task


  2. Use Thunder download task information call the object query

sFileSize = ThunderEng.GetTaskInfo (txtURL.Text, "FileSize ") ' Get the download file size
sDownedSize = ThunderEng.GetTaskInfo (txtURL.Text, "CompletedSize ")' has completed the acquisition size
sFileName = ThunderEng.GetTaskInfo (txtURL.Text, "FileName ") 'get the file name

  Second, the Thunder platform interface function definition

  get information

  1. BSTR GetInfo(BSTR pInfoName)

  Function: get Thunder or platform-related information

  parameter:

Parameter name Meaning
pInfoName information name, there are the following four
. "ThunderExists": the existence of Thunder
. "ThunderRunning": Thunder is running
. "ThunderVersion": Thunder version number
. "PlatformVersion": platform version number

  Return Value: returns the parameter value is a string corresponding relationship pInfoName

Parameters Value returned
"ThunderExists" "true" existence, "false" does not exist
"ThunderRunning" "true" run, "false" not running
"ThunderVersion" Thunder version number "xxxx"
"platformVersion" platform version number "xxxx"

  2. HRESULT GetInfoStruct(INT pInfo)

  Function: Get all the relevant information or platform Thunder

  parameter:

Parameter Name Meaning
pInfo fact THUNDER_INFO structure pointer type, convert it to before calling INT type; internet after a call information structure will be filled with

,定义如下:
typedef struct _THUNDER_INFO
{
BOOL bThunderExists;
BOOL bThunderRunning;
CHAR szThunderVersion[32];
CHAR szPlatformVersion[32];
} THUNDER_INFO;

After the function call, the appropriate information in the structured packing.

  return value:

0 for success
non-zero acquisition failure

Task Action

  3. Add task

HRESULT AddTask
(BSTR pURL,
BSTR pFileName = "",
BSTR pPath = "",
BSTR pComments = "",
BSTR pReferURL = "",
INT nStartMode = -1,
INT nOnlyFromOrigin = 0,
INT nOriginThreadCount = -1);

  Features:

  Add download task information to the platform, this time to the Thunder has not been reflected in

  parameter:

Parameter name Meaning
pURL target URL, the parameters must
pFileName Save name, the default is blank, handled by the Thunder, optional parameters
pPath storage directory, the default is blank, handled by the Thunder, optional parameters
pComments download notes, empty by default, can be selected parameters
pReferURL reference page URL, the default is empty, optional parameters
nStartMode start mode, manual start 0, 1 start immediately, the default is -1, which is handled by the Thunder, optional parameters
if nOnlyFromOrigin download only from the original URL, from a the original URL download, download resources over 0, the default is 0, the optional parameter
nOriginThreadCount original address download threads, the range of 1-10, the default is -1, which is handled by the Thunder, optional parameters

  4. Start task

  HRESULT CommitTaskss()

  Features:

  Download the AddTask added real task information submitted to the Thunder download, and delete from the platform

  Note: If the task has not been submitted to add AddTask not been canceled (call CancelTasks), the Agent will be when the object destruction

Blocking, so the caller does not leave some tasks should not be submitted or canceled to avoid script execution to stop responding.

  5. Cancellation mission

  HRESULT CancelTasks()

  Features:

  Cancel all download tasks by the AddTask added information platform

  6. Query task information

  BSTR GetTaskInfo(BSTR pURL,BSTR pInfoName);

  parameter:

Parameter name Meaning
download URL pURL information to be queried
pInfoName state name, there are several

. "Exists": pURL whether the task list in Thunder
. "Path": storage directory
. "FileName": file name
. "FileSize": file size
. "CompletedSize": Downloaded size
. "Percent": Download progress
. "Status": Task Status

  Return Value: returns the parameter value is a string corresponding relationship pInfoName

Arguments Return Value
"Exists" "true" presence, "false" absent
"Path" storage directory, and finally with a backslash \, Example: C: \ TDDownload \
"FileName" file name
"FileSize" file size in bytes units, 0 indicates an unknown size
"CompletedSize" downloaded size, in bytes
"Percent" download progress with a decimal Example: 70.0
"the status" task state, the following six states

. "Running": operating status
. "Stopped": Stop state
. "Failed": the failed state
. "Success": a successful state
. "Creatingfile": Creating a data file
. "Connecting": Connecting

  7. GetTaskInfoStruct(INT pTaskInfo)

  Function: Query a task all the information

Parameter Name Meaning
pTaskInfo fact THUNDER_TASKINFO structure pointer type, convert it to before calling INT type; call after filling in the structure

Platform information, is defined as follows:

struct _THUNDER_TASKINFO typedef
{
CHAR szURL [1024]; // task URL, prefilled
BOOL bTaskExists; // if there are tasks, TRUE is present
CHAR szPath [256]; // save the downloaded local path
CHAR szFileName [256]; // local file name
ULONGLONG nFileSize; // file size
ULONGLONG nCompletedSize; // finished size
CHAR szPercent [16]; // completion percentage, with "56.8" format
CHAR szStatus [16]; // current status, as defined in GetTaskInfo function
} THUNDER_TASKINFO;

The caller first fills szURL members of the structure, to specify the tasks that need to query the URL, and then after the function returns and so can other members from

Obtain information about the task. 
The present embodiment all of the code

System Imports
Imports System.Text
Public Class frmThunderClass frmThunder
Private _iStartMode of As Integer 'Thunder download task start mode
Private ThunderEng As New THUNDERAGENTLib.Agent' creation Thunder calling object
Private Sub frmThunder_Load () Sub frmThunder_Load ( ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCancel_Click()Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles btnCancel.Click
Close()
End Sub
'开始下载任务
Private Sub btnStartDown_Click()Sub btnStartDown_Click(ByVal sender As System.Object, ByVal

e As System.EventArgs) Handles btnStartDown.Click
Dim iOnlyFromOrigin, iOriginThreadCount As Integer
iOnlyFromOrigin = IIf(chkOnlyFromOrigin.Checked = True, 1, 0)
iOriginThreadCount = CInt(txtOriginThreadCounts.Text)
If chkDefault.Checked Then
iOriginThreadCount = -1
End If
ThunderEng.AddTask(txtURL.Text, txtSaveAsFileName.Text, txtSaveDir.Text, txtComment.Text, _
txtReferencePage.Text, _iStartMode, iOnlyFromOrigin, iOriginThreadCount)
ThunderEng.CommitTasks()
Timer1.Enabled = True
End Sub


Private Sub radMaual_Click()Sub radMaual_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) the Handles radMaual.Click, radImmediate.Click, radDefault.Click
Dim the RadioButton RAD of As = the CType (SENDER, the RadioButton)
_iStartMode = the CInt (rad.Tag)
End Sub
'when the timing task starts query task download information
Private Sub Timer1_Tick () Sub Timer1_Tick (ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Timer1.Tick
Dim sFileSize, sDownedSize, sStatus, sFileName, sPercent As String
Try
sStatus = ThunderEng.GetTaskInfo(txtURL.Text, "Status")
sFileSize = ThunderEng.GetTaskInfo(txtURL.Text, "FileSize")
sDownedSize = ThunderEng.GetTaskInfo(txtURL.Text, "CompletedSize")
sFileName = ThunderEng.GetTaskInfo(txtURL.Text, "FileName")
lblDownedSize.Text = String.Format(lblDownedSize.Tag, sDownedSize)
lblFileSize.Text = String.Format(lblFileSize.Tag, sFileSize)
lblTaskStatus.Text = String.Format(lblTaskStatus.Tag, sStatus)
lblFilename.Text = String.Format(lblFilename.Tag, sFileName)
sPercent = ThunderEng.GetTaskInfo(txtURL.Text, "Percent") '获取下载百分比
lblProgress.Text = String.Format(lblProgress.Tag, sPercent.Remove(3, Len(sPercent) - 3))
Catch ex As Exception
End Try
End Sub
Private Sub chkOnlyFromOrigin_CheckedChanged_1()Sub chkOnlyFromOrigin_CheckedChanged_1(ByVal

sender As System.Object, ByVal e As System.EventArgs) Handles

chkOnlyFromOrigin.CheckedChanged
Panel1.Enabled = chkOnlyFromOrigin.Checked
End Sub
Private Sub GroupBox1_Enter()Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class

Go to Tools - Configuration - Advanced, IE context menu by the "Use Thunder download" option to add the task in front of the hook removed. 
Thunder remain open state, this time the implementation of the above script, you add tasks to confirm that the dialog box does not appear.

Guess you like

Origin www.cnblogs.com/stvadv/p/11688106.html