I found that _WinHttpOpenRequest cause error (DllCall Failed) many times when i try to run this func more than 3 times so what should i do ? Exactly, when i test this au3, it success and no error, But after many hours, i run au3 again, it seem very bad.
#include <winhttp.au3>
cngoogle()
cngoogle()
cngoogle()
Func cngoogle()
Global $hOpen = _WinHttpOpen("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/2.0.0.14;MEGAUPLOAD 1.0")
If @error Then
MsgBox(48, "Error", "Error initializing the usage of WinHTTP functions.")
Exit 1
EndIf
; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, "google.com")
If @error Then
MsgBox(48, "Error", "Error getting connection handle." & @CRLF & "Error number is " & @error)
Else
ConsoleWrite("+ Connection handle $hConnect = " & $hConnect & @CRLF)
MsgBox(64, "Yes!", "Handle is get! $hConnect = " & $hConnect)
EndIf
Global $hRequest = _WinHttpOpenRequest($hConnect, _
"GET", _
"/index.html", _
Default, _
"http://google.com/index.html", _
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
_WinHttpAddRequestHeaders($hRequest, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/2.0.0.14;MEGAUPLOAD 1.0")
_WinHttpSendRequest($hRequest, _
"Content-Type: application/x-www-form-urlencoded")
If @error Then
MsgBox(48, "Error", "OPENREQ FAILED")
EndIf
; Wait for the response
_WinHttpReceiveResponse($hRequest)
Global $sHeader = _WinHttpQueryHeaders($hRequest)
msgbox(0,"",$sHeader)
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
EndFunc