📄 form1.frm
字号:
Height = 255
Left = 120
TabIndex = 31
Top = 5160
Width = 9975
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "要下载的文件网址:"
Height = 180
Left = 120
TabIndex = 23
Top = 2760
Width = 1530
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "毫秒"
Height = 180
Left = 3960
TabIndex = 15
Top = 1320
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "超时时长:"
Height = 180
Left = 1920
TabIndex = 13
Top = 1320
Width = 810
End
Begin VB.Menu mnuFile
Caption = "文件(&F)"
Begin VB.Menu mnuBegin
Caption = "开始下载"
End
Begin VB.Menu mnuStop
Caption = "停止下载"
End
Begin VB.Menu mnuBar
Caption = "-"
End
Begin VB.Menu mnuReg
Caption = "购买控件"
End
Begin VB.Menu mnubar0
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "退出"
End
End
Begin VB.Menu mnuHelp
Caption = "帮助(&H)"
Begin VB.Menu mnuOcx
Caption = "控件使用帮助"
End
Begin VB.Menu mnuBar1
Caption = "-"
End
Begin VB.Menu mnuEmail
Caption = "作者信箱"
End
Begin VB.Menu mnuWeb
Caption = "作者主页"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
'金锋文件下载控件 3.0 下载文件的示例程序
'
'在使用DownFile方法下载文件时,如果要指定非常规服务器端口号,可以在服务器域名后加“:端口号”
'如:http://www.xxx.com:8080/xxx.zip、ftp://ftp.xxx.com:1000/xxx.zip
'
'在使用DownFile方法下载文件时,如果要指定HTTP或FTP服务器用户名密码可以像这样:
'ftp://用户名:密码@ftp.xxx.com/xxx.zip
'http://用户名:密码@www.xxx.com/xxx.zip
'
'本示例程序仅仅是简单的演示了在一般情况下使用《金锋文件下载控件》下载文件的方法。
'
'有关控件的一些重要属性、方法在某些特殊情况下的特殊作用等的说明请参略《金锋文件下载控件使用帮助》
'
'
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Check1_Click()
jfDownEX1.ShowText = Check1.Value
End Sub
Private Sub Command1_Click()
On Error GoTo p1
DLG.Flags = &H1 Or &H2
DLG.Color = jfDownEX1.BackColor
DLG.ShowColor
jfDownEX1.BackColor = DLG.Color '设置进度条背景色
p1:
End Sub
Private Sub Command2_Click()
On Error GoTo p1
DLG.Flags = &H1 Or &H2
DLG.Color = jfDownEX1.ForeColor
DLG.ShowColor
jfDownEX1.ForeColor = DLG.Color '设置进度条前景色
p1:
End Sub
Private Sub Command3_Click()
On Error GoTo p1
DLG.Flags = &H1 Or &H2
DLG.Color = jfDownEX1.Color
DLG.ShowColor
jfDownEX1.Color = DLG.Color
p1:
End Sub
Private Sub Command4_Click()
On Error GoTo p1
DLG.Flags = cdlCFScreenFonts
DLG.ShowFont
'设置进度条字体
jfDownEX1.Font.Bold = DLG.FontBold
jfDownEX1.Font.Italic = DLG.FontItalic
jfDownEX1.Font.Name = DLG.FontName
jfDownEX1.Font.Size = DLG.FontSize
jfDownEX1.Font.Underline = DLG.FontUnderline
jfDownEX1.Font.Strikethrough = DLG.FontStrikethru
p1:
End Sub
Private Sub Command5_Click()
ShellExecute hwnd, "open", "http://www.jinfengsoft.net/soft/jfdown/login.htm", "", "", 1
End Sub
Private Function CheckSet() As Boolean
CheckSet = False
If Trim(Text4.Text) = "" Then
MsgBox "请输入正确的网址!", 16 Or vbOKOnly
Exit Function
End If
jfDownEX1.ProxyServer = Text1.Text '设置代理服务器
jfDownEX1.ProxyPort = Val(Text2.Text) '设置代理服务器端口
jfDownEX1.UseProxy = Check3.Value '设置是否使用代理服务器
jfDownEX1.UseCookie = Check2.Value '设置是否使用Cookie
jfDownEX1.TimeOut = Val(Text1.Text) '设置超时时长
jfDownEX1.UseReferer = Check4.Value '设置是否使用提交方来源
jfDownEX1.Referer = Text5.Text '设置提交方来源地址(如果为空,控件将自动取文件下载的目录地址作为提交方来源)
CheckSet = True
End Function
Private Sub Command6_Click()
On Error GoTo p1
If Not CheckSet Then Exit Sub
DLG.Flags = &H2
DLG.ShowSave
If Dir(DLG.FileName, 0 + 1 + 2 + 4) <> "" Then
If MsgBox("是否使用断点续传功能?", vbYesNo + 32) = vbYes Then
jfDownEX1.DownFile Text4.Text, DLG.FileName, FileLen(DLG.FileName), True '从断点处续传文件
Exit Sub
Else
Kill DLG.FileName
End If
End If
jfDownEX1.DownFile Text4.Text, DLG.FileName, 0, True '从0字节处下载文件
p1:
End Sub
Private Sub Command7_Click()
If Not CheckSet Then Exit Sub
If jfDownEX1.GetUrlInfo(Text4.Text) Then
tmp = "文件名:" & jfDownEX1.ContentFilename & vbCrLf & "文件体积:" & jfDownEX1.FileLength & vbCrLf & "文件最后更新日期:" & jfDownEX1.Last_Modified & vbCrLf
tmp = tmp & "文件真实地址:"
If jfDownEX1.UseFtp Then
tmp = tmp & "ftp://"
If jfDownEX1.FtpUserName <> "anonymous" Then tmp = tmp & jfDownEX1.FtpUserName & ":" & jfDownEX1.FtpPassWord & "@"
tmp = tmp & jfDownEX1.Server
If jfDownEX1.Port <> 21 Then tmp = tmp & ":" & jfDownEX1.Port
tmp = tmp & jfDownEX1.FilePath
Else
tmp = tmp & "http://"
If jfDownEX1.UseHttpUser Then tmp = tmp & jfDownEX1.HttpUserName & ":" & jfDownEX1.HttpPassWord & "@"
tmp = tmp & jfDownEX1.Server
If jfDownEX1.Port <> 80 Then tmp = tmp & ":" & jfDownEX1.Port
tmp = tmp & jfDownEX1.FilePath
End If
MsgBox tmp, vbInformation
Else
MsgBox "获取文件属性失败!", 16
End If
Label6.Caption = "就绪"
'ContentFilename 属性返回要下载的文件的文件名
'FileLength 属性返回要下载的文件的体积
'Last_Modified 属性返回要下载的文件的最后更新时间
End Sub
Private Sub Command8_Click()
ShellExecute hwnd, "open", "http://www.softreg.com.cn/shareware_view.asp?id=/AB77B40C-778C-4B17-A0FB-3E4423A72E6C/#regform", "", "", 1
End Sub
Private Sub Command9_Click()
End
End Sub
Private Sub jfaddline(ByVal txt As String)
Text6.Text = Text6.Text & txt & vbCrLf
Text6.SelStart = Len(Text6.Text)
End Sub
Private Sub jfDownEX1_OnCompleted()
Label6.Caption = "下载完成"
End Sub
Private Sub jfDownEX1_OnError(ByVal ErrorMessage As String, ByVal ErrorID As Long)
jfaddline ("发生错误 " & ErrorID & ":" & ErrorMessage & ",关闭连接。")
jfDownEX1.CloseLink '关闭连接及打开的文件
End Sub
Private Sub jfDownEX1_OnGetData()
Label6.Caption = "正在下载(" & jfDownEX1.Progress & "/" & jfDownEX1.FileLength & ")..."
'Progress 属性返回当前文件下载进度(以字节为单位,即返回已下载了多少字节)
End Sub
Private Sub jfDownEX1_OnKilllink()
jfaddline ("已断开连接")
End Sub
Private Sub jfDownEX1_OnLinked()
Label6.Caption = "已连接到" & jfDownEX1.Server
jfaddline "已连接" & jfDownEX1.Server
End Sub
Private Sub jfDownEX1_OnLinking()
Label6.Caption = "正在连接" & jfDownEX1.Server & "..."
jfaddline "正在连接" & jfDownEX1.Server & "..."
End Sub
Private Sub jfDownEX1_OnRecvCommand(ByVal CommandStr As String) '当控件向服务器发送命令时发生该事件
jfaddline (CommandStr)
' CommandStr 是控件向服务器发送的命令(但并不完全是,有些是控件自加的信息)
End Sub
Private Sub jfDownEX1_OnSendCommand(ByVal CommandStr As String) '当服务器返回信息时发生该事件
jfaddline (CommandStr)
' CommandStr 是服务器返回的命令(但并不完全是,有些是控件自加的信息)
End Sub
Private Sub mnuBegin_Click()
Command6_Click
End Sub
Private Sub mnuEmail_Click()
jfDownEX1.GetSupport
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuOcx_Click()
ShellExecute hwnd, "open", "http://www.jinfengsoft.net/soft/jfdown/index.htm", "", "", 1
End Sub
Private Sub mnuReg_Click()
Command8_Click
End Sub
Private Sub mnuStop_Click()
jfDownEX1.CloseLink
End Sub
Private Sub mnuWeb_Click()
jfDownEX1.GotoWeb
End Sub
Private Sub Option1_Click(Index As Integer)
jfDownEX1.Kind = Index
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -