microsoft internet transfer control 使用简介
example:
dim objinet
set objinet = server.createobject("inetctls.inet.1")
在vb里面先把它加到部件里,然后直接放到form上面就可以了
1.get http page
strhtml = objinet.openurl(strurl)
或者
objinet.url = strurl
strhtml = objinet.openurl
2.get http file
我还不知道在asp里面怎么用,有知道的请指点。
dim b() as byte
b() = objinet.openurl(strurl, icbytearray)
if ubound(b) < 1 then
strerrormsg = "无法打开该url地址!"
else
open filename for binary access write as #1
put #1, , b()
close #1
end if
3.get ftp file
如果不是匿名的话
objinet.username = "yourname"
objinet.password = "yourpass"
objinet.url = "ftp://ftp.pku.edu.cn"
objinet.execute , "cd dir1"
objinet.execute , "get xx.exe c:\download\xx.exe"
objinet.execute , "quit"
4.list ftp files
objinet.url = "ftp://ftp.pku.edu.cn"
objinet.execute , "dir /dir1"
private sub objinet_statechanged(byval state as integer)
因为execute方法执行后并不是马上返回结果的,所以必须在statechanged事件中处理
dim vtdata as variant 数据变量。
dim strdata as string: strdata = ""
dim bdone as boolean: bdone = false
if state = 12 then
vtdata = objinet.getchunk(1024, icstring)
doevents
do while not bdone
strdata = strdata & vtdata
doevents
vtdata = objinet.getchunk(1024, icstring)
if len(vtdata) = 0 then
bdone = true
end if
loop
end if
msgbox(strdata)
end sub
5.use proxy server
objinet.proxy = "proxy.io.com:3128"
objinet.accesstype = icnamedproxy
6.use http get & post
objinet.execute "http://www.chinaasp.com/sqlbbs/wwwboard.asp", "get", "id=1"
要用post只需要把get那几个字符换一下就可以了,取得返回值的方法同4
我想基本上的功能都可以满足了,有空再写属性和方法、事件介绍。我本来是打算写一个ocx控件来调用这个,简化它的使用的,这样调用起来就方便的多了,因为有些功能不可以直接在asp里面使用,尤其是对于一些ftp命令和错误处理。(还有一个原因是我不知道怎么把这个msinet.ocx安装到别的机器上,但是我自己写一个程序调用它,再做安装盘,安装后就可以用了)
