SetBatchLines, -1
zlibPath := "D:\Downloads\zlib\bin\zlib1.dll"
oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", "http://ahkscript.org/boards/", false)
oHTTP.SetRequestHeader("Accept-Encoding", "gzip, deflate")
oHTTP.Send()
arr := oHTTP.ResponseBody
length := arr.MaxIndex() + 1
pData := NumGet( ComObjValue(arr) + 8 + A_PtrSize )
start := A_TickCount
size := gzip_inflate(zlibPath, pData, length, uncompr)
res := StrGet(&uncompr, size, "utf-8")
MsgBox, % "Завершено за " . A_TickCount - start . " мс`n`n" . res
gzip_inflate(zlib, pComprData, comprLen, ByRef uncompr) {
static MAX_WBITS := 15, Z_OK := 0, Z_FINISH := 4, Z_STREAM_END := 1
, errors := ["Z_ERRNO", "Z_STREAM_ERROR", "Z_DATA_ERROR", "Z_MEM_ERROR", "Z_BUF_ERROR", "Z_VERSION_ERROR"]
if !hLib := DllCall("LoadLibrary", Str, zlib, Ptr)
throw Exception("Can't load zlib1.dll. A_LastError: " . A_LastError)
VarSetCapacity(uncompr, outMaxLen := comprLen*10, 0)
VarSetCapacity(stream, szStream := 24 + 8*A_PtrSize, 0)
NumPut(pComprData, stream)
NumPut(comprLen, stream, A_PtrSize, "UInt")
NumPut(&uncompr, stream, A_PtrSize + 8)
NumPut(outMaxLen, stream, A_PtrSize + 8 + A_PtrSize, "UInt")
Loop 1 {
res := DllCall(zlib . "\inflateInit2_", Ptr, &stream, Int, 16 + MAX_WBITS, AStr, "1", Int, szStream)
if ( res != Z_OK && error := "inflateInit2_: " . errors[-res] )
break
res := DllCall(zlib . "\inflate", Ptr, &stream, Int, Z_FINISH)
if ( res != Z_STREAM_END && error := "inflate: " . errors[-res] )
break
res := DllCall(zlib . "\inflateEnd", Ptr, &stream)
( res != Z_OK && error := "inflateEnd: " . errors[-res] )
}
DllCall("FreeLibrary", Ptr, hLib)
if error
throw Exception(error)
Return outLen := NumGet(stream, A_PtrSize + 8 + A_PtrSize + 4, "UInt")
}
Не знаю, всё ли правильно.