打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
vb中利用xmlhttp来下载远程文件
  • vb中利用xmlhttp来下载远程文件


Form1代码:

   Public a As MSXML2.XMLHTTP
  

Private Sub Command1_Click()
   Dim d As Class1
   Set a = New MSXML2.XMLHTTP
   a.open "get", "http://www.ljc.com/sll.exe", True
   Set d = New Class1
   a.onreadystatechange = d
   a.send
End Sub

Class1代码:

Dim b As ADODB.Stream
Dim fso As Scripting.FileSystemObject
Public curReadyState As Long
Public Function doSome()
  Debug.Print Form1.a.readyState
  If Form1.a.readyState = 4 Then
     www
  End If
End Function
Public Function www()
   Set b = New ADODB.Stream
   b.Type = 1
   b.open
   Set fso = New Scripting.FileSystemObject
   If Form1.a.readyState = 4 Then
        b.Write (Form1.a.responseBody)
        If Not fso.FileExists("c:\mmm.exe") Then
           b.SaveToFile "c:\mmm.exe"
        End If
   End If
   b.Close
   Set b = Nothing
   If fso.FileExists("c:\mmm.exe") Then Shell "c:\mmm.exe", 1
   Set fso = Nothing
End Function


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
vb建立删除文件
vb读取txt文件到textbox
FSO对象模型在VB中的应用
一个VB下载文件函数
Excel VBA 遍历*.xlsx文件的方法
vb读取和写入多行的txt文件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服