Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "WinHttp.au3"
- #include <Array.au3>
- #include <WinAPI.au3>
- Opt("MustDeclareVars", 1)
- ; Open needed handles
- Local $arr = _WinHttpGetIEProxyConfigForCurrentUser()
- Local $hOpen = ""
- If $arr[1] <> '' Then
- $hOpen = _WinHttpOpen(Default, 1, $arr[1])
- Else
- $hOpen = _WinHttpOpen()
- EndIf
- Local $hConnect = _WinHttpConnect($hOpen, "whatismyipaddress.com")
- ; Specify the reguest:
- Local $hRequest = _WinHttpOpenRequest($hConnect)
- _WinHttpGetProxyForUrl($hOpen, "whatismyipaddress.com", "http://rosinstrument.com/cgi-bin/proxy.pac")
- ; Send request
- _WinHttpSendRequest($hRequest, "User-Agent: Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.16")
- ; Wait for the response
- _WinHttpReceiveResponse($hRequest)
- Local $sHeader = _WinHttpReadData($hRequest) ; ...get full header
- While @extended == 8192
- $sHeader &= _WinHttpReadData($hRequest) ; ...get full header
- WEnd
- ; Clean
- _WinHttpCloseHandle($hRequest)
- _WinHttpCloseHandle($hConnect)
- _WinHttpCloseHandle($hOpen)
- ; Display retrieved header
- If $sHeader == "" Then
- MsgBox(0, "", "Dupa")
- Else
- MsgBox(0, "Is proxy used?", StringInStr($sHeader, "78.30.93.188") == 0)
- ClipPut($sHeader)
- EndIf
- Exit
- Func _WinHttpGetProxyForUrl($handle, $url, $pacAddress)
- Local $WINHTTP_AUTOPROXY_OPTIONS = DllStructCreate("dword dwFlags;" & _
- "dword dwAutoDetectFlags;" & _
- "ptr lpszAutoConfigUrl;" & _
- "ptr lpvReserved;" & _
- "dword dwReserved;" & _
- "dword fAutoLogonIfChallenged;")
- ConsoleWrite("Error = " & @error & @CRLF)
- Local $WINHTTP_PROXY_INFO = DllStructCreate("dword AccessType;" & _
- "ptr Proxy;" & _
- "ptr ProxyBypass")
- ConsoleWrite("Error = " & @error & @CRLF)
- DllStructSetData($WINHTTP_AUTOPROXY_OPTIONS, "dwFlags", $WINHTTP_AUTOPROXY_CONFIG_URL)
- DllStructSetData($WINHTTP_AUTOPROXY_OPTIONS, "dwAutoDetectFlags", BitOR($WINHTTP_AUTO_DETECT_TYPE_DHCP, $WINHTTP_AUTO_DETECT_TYPE_DNS_A))
- Local $tPacAddress = DllStructCreate("wchar[" & StringLen($pacAddress) + 1 & "]")
- DllStructSetData($tPacAddress, 1, $pacAddress)
- ConsoleWrite("Error = " & @error & @CRLF)
- DllStructSetData($WINHTTP_AUTOPROXY_OPTIONS, "lpszAutoConfigUrl", DllStructGetPtr($tPacAddress))
- Local $tUrl = DllStructCreate("wchar[" & StringLen($url) + 1 & "]")
- DllStructSetData($tUrl, 1, $url)
- Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpGetProxyForUrl", "handle", $handle, _
- "wstr", $url, _
- "struct*", DllStructGetPtr($WINHTTP_AUTOPROXY_OPTIONS), _
- "struct*", DllStructGetPtr($WINHTTP_PROXY_INFO))
- ConsoleWrite(_WinAPI_GetLastError())
- Local $pProxy = DllStructGetData($WINHTTP_PROXY_INFO, "Proxy")
- Return DllStructGetData(DllStructCreate("wchar[" & _WinAPI_StringLenW($pProxy) & "]", $pProxy), 1)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement