2
我最近意識到URLDownloadToFile使用IE代理設置。所以我正在尋找替代方法,並發現WinHttp.WinHttpRequest可能工作。用WinHttp.WinHttpRequest查找檢索到的二進制數據的大小
似乎ResponseBody屬性包含提取的數據,我需要將它寫入文件。問題是我無法找到它的字節大小。
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384106%28v=vs.85%29.aspx有對象的信息,但我沒有找到它的相關屬性。
有人可以告訴如何?
strURL := "http://www.mozilla.org/media/img/sandstone/buttons/firefox-large.png"
strFilePath := A_ScriptDir "\dl.jpg"
pwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
pwhr.Open("GET", strURL)
pwhr.Send()
if (psfa := pwhr.ResponseBody) {
oFile := FileOpen(strFilePath, "w")
; msgbox % ComObjType(psfa) ; 8209
oFile.RawWrite(psfa, strLen(psfa)) ; not working
oFile.Close()
}