VB + API Gets the "Proxy Server" formulation of IE

zhaozj2021-02-08  310

Option ExplicitPrivate Type INTERNET_PROXY_INFO dwAccessType As Long lpszProxy As Long lpszProxyBypass As LongEnd TypePrivate Const INTERNET_OPTION_PROXY = 38Private 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 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 LongPrivate 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 LongPrivate Declare Function lstrlen Lib" kernel32 "Alias "LSTRLENA" (Byval LPSTRING ANY) AS Longpublic Function GetProxyAddressandport (Optional Proxytype As String) AS StringDim ProxyInfo As INTERNET_PROXY_INFODim arrBuffer () As ByteDim strAddress As StringDim strBypass As StringReDim arrBuffer (0 To 4095) InternetQueryOption 0 &, INTERNET_OPTION_PROXY, arrBuffer (0), UBound (arrBuffer) - LBound (arrBuffer) 1CopyMemory ProxyInfo, arrBuffer (0), LenB (ProxyInfo) strAddress = VBA.Space (lstrlen (ProxyInfo.lpszProxy)) lstrcpy ByVal strAddress, ProxyInfo.lpszProxy 'without using the proxy address strBypassstrBypass = VBA.Space (lstrlen (ProxyInfo.lpszProxyBypass)) lstrcpy ByVal strBypass, ProxyInfo.lpszProxyBypass' GetProxyaddressandport = VBA.trim (VBA.Replace (straddress, ","; ")) '&"; "

转载请注明原文地址:https://www.9cbs.com/read-1077.html

New Post(0)