如何设置WebBrowser控件不使用代理(ie设置了代理)附VB代码
本帖最后由 xzxnovice 于 2011-10-11 13:21 编辑ie设置了使用代理,想用au加入ie的控件实现绕过ie代理的目的。。
附一段vb上正常使用的代码Option Explicit
Private Type INTERNET_PROXY_INFO
dwAccessType As Long
lpszProxy As String
lpszProxyBypass As String
End Type
Private Const INTERNET_OPTION_PROXY = 38
Private Const INTERNET_OPTION_SETTINGS_CHANGED = 39
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_OPEN_TYPE_PROXY = 3
Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByRef lpBuffer As Any, ByVal dwBufferLength As Long) As Long
Private Sub SetProxy(aStrIP As String, aStrPort As String, aBolUseProxy As Boolean)
Dim strProxy As String
Dim inf As INTERNET_PROXY_INFO
aStrIP = Trim(aStrIP)
aStrPort = Trim(aStrPort)
If (aStrIP + aStrPort = "") Or Not aBolUseProxy Then
strProxy = ""
Else
strProxy = "http=" + aStrIP + ":" + aStrPort
End If
If Trim(strProxy) <> "" Then
inf.dwAccessType = INTERNET_OPEN_TYPE_PROXY
inf.lpszProxy = strProxy
inf.lpszProxyBypass = ""
Call InternetSetOption(0, INTERNET_OPTION_PROXY, inf, Len(inf))
Call InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, "", 0)
Else
inf.dwAccessType = INTERNET_OPEN_TYPE_DIRECT
inf.lpszProxy = ""
inf.lpszProxyBypass = ""
Call InternetSetOption(0, INTERNET_OPTION_PROXY, inf, Len(inf))
Call InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, "", 0)
End If
End Sub
Private Sub Command1_Click()
SetProxy txtIP.Text, txtPort.Text, True
WebBrowser1.Navigate "http://www.tbgwj.com"
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.tbgwj.com"
End Sub 这个很难。。。。。。 _WinINet_InternetSetOption 应该可以。但还不会用 $inf = DllStructCreate($tagINTERNET_PROXY_INFO)
DllStructSetData($inf, "AccessType", $INTERNET_OPEN_TYPE_DIRECT)
DllStructSetData($inf, "Proxy", "")
DllStructSetData($inf, "ProxyBypass", "")
$msg=_WinINet_InternetSetOption(0,$INTERNET_OPTION_PROXY, $inf)
ConsoleWrite($msg&@CRLF)
$msg=_WinINet_InternetSetOption(0,$INTERNET_OPTION_SETTINGS_CHANGED,"")
ConsoleWrite($msg&@CRLF)
不知哪里错,第一句就返回false了。 自己顶一下
页:
[1]