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