I'm trying to POST by using WinINet.
but i stucked at calling HttpOpenRequestA.
I get 87 of A_LastError which means ERROR_INVALID_PARAMETER
even if i put 0 for last 5 parameters of HttpOpenRequestA, it returns 122 of A_LastEror which means ERROR_INSUFFICIENT_BUFFER
anyone have idea for it?
Thanks for reading.
My attempt is below
Code:
hModule := DllCall("LoadLibrary", "Str", "WinInet.Dll")
;---------------------------------------------------------------
Agent := "AutoHotkey"
hInternet := DllCall("WinINet\InternetOpenA"
, "Str*", Agent
, "Int" , 4
, "Str*", 0
, "Str*", 0
, "Uint", 0)
;Working
MsgBox % hInternet " / " ErrorLevel " / " A_LastError
;---------------------------------------------------------------
ServerName := "www.autohotkey.com/forum"
hConnect := DllCall("WinINet\InternetConnectA"
, "uInt", hInternet
, "Str*", ServerName
, "Int" , 80 ;INTERNET_DEFAULT_HTTP_PORT
, "Str*", 0 ;UserName
, "Str*", 0 ;Password
, "uInt", 3 ;INTERNET_SERVICE_HTTP
, "uInt", 0
, "uInt*", 0)
;Working
MsgBox % hConnect " / " ErrorLevel " / " A_LastError
;---------------------------------------------------------------
HTTPVerb := "POST"
ObjectName := "search.php"
Version := ""
Referer := ""
AcceptTypes := ""
Flags := ""
Context := ""
hRequest := DllCall("WinINet\HttpOpenRequestA"
, "uInt", hConnect
, "Str*", HTTPVerb
, "Str*", ObjectName
, "Str*" , Version ;Version
, "Str*" , Referer ;Referer
, "Str*" , AcceptTypes ;AcceptTypes
, "uInt" , Flags ;Flags
, "uInt*" , Context ) ;Context
;Not Working with A_LastError 87 (ERROR_INVALID_PARAMETER)
MsgBox % hRequest " / " ErrorLevel " / " A_LastError
;---------------------------------------------------------------
DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
DllCall("FreeLibrary", "UInt", hModule)
_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at
PlayAHK.com