有人愿意帮忙测试几行代码吗?
下面的这片代码是设置代理ip并且刷新的。可是我试了几次没有效果。在打开id的选项那边查看,发现并没有改变。
打开注册表 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings,查看ProxyServer的值发现也没有变化,不知道是怎么回事。我的是xp系统。
Option ExplicitPrivate 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 LongPrivate Type INTERNET_PROXY_INFO dwAccessType As Long lpszProxy As String lpszProxyBypass As StringEnd TypePrivate Const INTERNET_OPTION_PROXY = 38Private Const INTERNET_OPTION_SETTINGS_CHANGED = 39Private Const INTERNET_OPEN_TYPE_DIRECT = 1Private Const INTERNET_OPEN_TYPE_PROXY = 3 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 IfEnd Sub'===使用代理上网Private Sub Command1_Click() SetProxy "123.10.10.233", "80", TrueEnd Sub '===不使用代理上网Private Sub Command2_Click() SetProxy "123.10.10.233", "80", FalseEnd Sub