I'm still having a problem with the HINTERNET handle.
I just checked it in visual studio, it should be the same as LPVOID. "typedef LPVOID HINTERNET;"
And LPVOID should be UPTR in AHK. But when I use the returned handle of WinHttpOpen in WinHttpConnect A_LastError contains 6, which means
the handle is invalid.
Code: Select all
LPCWSTR:="UPTR"
DWORD:="UInt"
LPCVOID:="UPTR"
LPDWORD:="UPTR"
HINTERNET:="UPTR" ;LPVOID
INTERNET_PORT:="UShort" ;WORD
userAgent := "AHK TestAgent"
proxy := "" ;localhost:8888
;proxyType := (proxy) ? 3 : 1
asynch := False
bypassProxyHostList := "localhost;127.0.0.1"
hSession := DllCall("Winhttp.dll\WinHttpOpen",LPCWSTR,&userAgent,DWORD,(proxy)?3:1,LPCWSTR,&proxy,LPCWSTR,&bypassProxyHostList,DWORD,asynch)
hostName := "www.google.com"
https := False
If (hSession)
hConnect := DllCall("Winhttp.dll\WinHttpConnect",HINTERNET,&hSession,LPCWSTR,&hostName,INTERNET_PORT,(https)?443:80,DWORD,0)
Else
Msgbox % "hSession error: " A_LastError
;...
If (hConnect)
;...
Else
Msgbox % "hConnect error: " A_LastError
eidt:
Ahhh, hold up, my mistake. I passed the address of the handle. But since the handle already is a pointer I had to pass it directly.
Great, it seems to work!