1、vb 如何测试代理服务器是否可用
Private Sub Command1_Click()
Dim OBJWMIService, colPings, OBJStatus
Dim i As Integer, WebAddress As String
WebAddress = "62.58.52.18" '请修改代理服务器地址
Set OBJWMIService = GetObject("winmgmts:\.
ootcimv2")
If WebAddress <> "" Then
Set colPings = OBJWMIService.ExecQuery("Select * From Win32_PingStatus Where Address = '" & WebAddress & "'")
For Each OBJStatus In colPings
If IsNull(OBJStatus.StatusCode) Or OBJStatus.StatusCode <> 0 Then
MsgBox "连接不通。。。"
Else
MsgBox "pinging [" & WebAddress & "] one time with " & OBJStatus.BufferSize & "bytes of data:" & Chr(10) & Chr(10) & "Reply from " & OBJStatus.ProtocolAddress & ": bytes=" & OBJStatus.BufferSize & " time=" & OBJStatus.ResponseTime & "ms TTL=" & OBJStatus.ResponseTimeToLive, , "连接成功!"
End If
Next
End If
Set OBJStatus = Nothing
Set colPings = Nothing
Set OBJWMIService = Nothing
End Sub
2、用VB如何做个代理服务器检测程序
可以用Inet控件来实现:思路,让Inet用代理访问百度并获取源代码,如果能从源代码找到百度之类的字眼就可以了。
方法:
工程-添加部件-找到microsoft internet transfer control 6.0
private sub form_load()
inet1.Proxy="192.168.1.100:3128"
dim temp as string
temp=inet1.openurl("www.baidu.com")
if instr(temp,"百度")>0 then
'有效
else
'无效
end if
end sub
3、vb 编写的HTTP代理上网
晕死,你的IP当然还是你的IP,这个只是修改IE的上网代理服务器设置而已,和你的本地IP地址根本没有任何关系。
请参考:
怎样设置IE浏览器代理服务器_百度经验
http://jingyan.baidu.com/article/2fb0ba404f4f4e00f2ec5fd4.html