[edit]
made the buffer from 3 to 256
[/edit]
[edit2]
removed
[/edit2]
[edit3]
stripping leftover @CR & @LF at the end
[/edit3]
[edit4]
instead of looping i just trim the last 2 chars to get rid of the leftover enter
reduced filesize a bit
removed edit 2 since it does support ftp://
[/edit4]
[edit5]
added support for Headers & changed user-agent to "AutoIt v3"
[/edit5]
Func _INetGetSource($s_URL, $s_Header = '') Local $h_DLL = DllOpen("wininet.dll"), $ai_IO, $ai_IOU, $ai_ICH, $ai_IRF[5] = [0, 0, '', 0, 1], $s_Buf = '' $ai_IO = DllCall($h_DLL, 'int', 'InternetOpen', 'str', "AutoIt v3", 'int', 0, 'str', '', 'str', '', 'int', 0) If @error Or $ai_IO[0] = 0 Then DllClose($h_DLL) SetError(1) Return 0 EndIf $ai_IOU = DllCall($h_DLL, 'int', 'InternetOpenUrl', 'int', $ai_IO[0], 'str', $s_URL, 'str', $s_Header, 'int', StringLen($s_Header), 'int', 0x80000000, 'int', 0) If @error Or $ai_IOU[0] = 0 Then DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0]) DllClose($h_DLL) SetError(1) Return 0 EndIf Local $v_Struct = DllStructCreate ('udword') While $ai_IRF[4] <> 0 $s_Buf &= StringMid($ai_IRF[2], 1, $ai_IRF[4]) $ai_IRF = DllCall($h_DLL, 'int', 'InternetReadFile', 'int', $ai_IOU[0], 'str', "", 'int', 256, 'ptr', DllStructGetPtr ($v_Struct, 1)) $ai_IRF[4] = DllStructGetData ($v_Struct, 1) WEnd DllStructDelete ($v_Struct) DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IOU[0]) DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0]) DllClose($h_DLL) Return StringTrimRight($s_Buf, 1) EndFunc;==>_INetGetSource
ConsoleWrite(_INetGetSource('http://www.autoitscript.com') & @LF)
to make cameronsdad happy:
(related to InternetReadFile)
LPVOID had nothing to do with it, just using 'str' was good.
the problem was with "LPDWORD lpdwNumberOfBytesRead" i first just used a 0 and now i use Dllstruct (im sure there is a cleaner way
Edited by w0uter, 27 September 2005 - 04:49 PM.





