用API函数下载文件


【实例说明】
    下载工具软件的一个功能。

【编程思路】
    调用API函数。

【设计步骤】
    1.新建一个标准工程,创建一个新窗体,默认名为Form1。
    2.在窗体上放置一个TextBox控件(用来输入所要下载文件的URL)、两个CommandButton控件。

    3.源程序  [素材源程序下载]


Option Explicit

'API函数声明
Private Declare Function DoFileDownload Lib "shdocvw.dll" _
        (ByVal lpszFile As String) As Long

Private Sub Form_Load()
        Text1.Text = "http://vbw.icpcn.com"
End Sub

'下载
Private Sub Command1_Click()
        Dim sDownload As String
        sDownload = StrConv(Text1.Text, vbUnicode)
        Call DoFileDownload(sDownload)
End Sub

Private Sub Command2_Click()
        End
End Sub