Option Explicit Private Type INTERNET_PROXY_INFO dwAccessType As Long lpszProxy As Long lpszProxyBypass As Long End Type Private Const INTERNET_OPTION_PROXY = 38 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 Declare Function InternetQueryOption Lib "wininet.dll" Alias "InternetQueryOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByRef lpBuffer As Any, ByRef dwBufferLength As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef pDest As Any, ByRef pSource As Any, ByVal Length As Long) Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Any) As Long Public Function GetProxyAddressAndPort(Optional ProxyType As String) As String Dim ProxyInfo As INTERNET_PROXY_INFO Dim arrBuffer() As Byte Dim strAddress As String Dim strBypass As String ReDim arrBuffer(0 To 4095) InternetQueryOption 0&, INTERNET_OPTION_PROXY, arrBuffer(0), UBound(arrBuffer) - LBound(arrBuffer) + 1 CopyMemory ProxyInfo, arrBuffer(0), LenB(ProxyInfo) strAddress = VBA.Space(lstrlen(ProxyInfo.lpszProxy)) lstrcpy ByVal strAddress, ProxyInfo.lpszProxy ''''不使用代理的地址 strBypass strBypass = VBA.Space(lstrlen(ProxyInfo.lpszProxyBypass)) lstrcpy ByVal strBypass, ProxyInfo.lpszProxyBypass ''''GetProxyAddressAndPort = VBA.Trim(VBA.Replace(strAddress, " ", ";")) '''' & ";" & VBA.Replace(strBypass, " ", ";")) GetProxyAddressAndPort = VBA.Trim(VBA.Replace(strAddress, " ", ";") & ";" & VBA.Replace(strBypass, " ", ";")) Dim ProxyArray() As String ProxyArray = Split(GetProxyAddressAndPort, ";") Dim i As Integer For i = LBound(ProxyArray) To UBound(ProxyArray) If ProxyArray(i) Like "*" & ProxyType & "=*" Then GetProxyAddressAndPort = VBA.Replace(ProxyArray(i), ProxyType & "=", "") Exit For End If Next i End Function
Private Sub Command1_Click() MsgBox GetProxyAddressAndPort("http") MsgBox GetProxyAddressAndPort("ftp") MsgBox GetProxyAddressAndPort("gopher") End Sub
''''编程配置 IE 的 "代理服务器" 要用到 InternetSetOption ''''一个例子下载: ''''http://www.vbip.com/forum/files/webbrowser_proxy.zip
[VB.NET程序]GSM短信模块库函数,可以用VB,VC,调用简单实用 [网页制作]Javascript获取各种浏览器可见窗口大小 [办公软件]PowerPoint做交互课件之弃用VBA [办公软件]VBA获取U盘、主板、CPU序列号和网卡MAC地址 [办公软件]VBA设置文件属性及加密源代码示例 [办公软件]VBA中初始化ADO连接的几种方法 [网络安全]“VB破坏者变种N”病毒摘要 [Sql Server]Sql精妙语句--各种求值函数 [Web开发]net.下如何获取网卡与主板系列号 [Web开发]ASP.NET上传文件到数据库VB版
|