Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Function : InternetFileRead() aka UrlDownLoadToVar()


  • Please log in to reply
161 replies to this topic
Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
Busy? Not quite. But I feel out of place here, since nobody cares about my 9x anymore. If I ever feel like working on some script, it'd be useless to post it since it'd be non AHK_L-compatible and mostly Win9x-oriented.

I'll keep getting post updates and every once in a while I may be back for minor fixes or just visiting, like a grown up that comes back to visit his childhood home from time to time.

Good luck with your projects and stay safe! :)

(AHK 1.0.48.05 and Win98SE) forever | My scripts are here


  • Guests
  • Last active:
  • Joined: --
Is this fully compatible with _L x86 Unicode? I tried the _Lx version posted here. However, when I run the first example, I get lots of Chinese characters. Other examples runs fine though.

Scoox
  • Members
  • 194 posts
  • Last active: Jun 09 2017 03:34 AM
  • Joined: 28 Nov 2010

Busy? Not quite. But I feel out of place here, since nobody cares about my 9x anymore. If I ever feel like working on some script, it'd be useless to post it since it'd be non AHK_L-compatible and mostly Win9x-oriented.


I'll keep getting post updates and every once in a while I may be back for minor fixes or just visiting, like a grown up that comes back to visit his childhood home from time to time.


Good luck with your projects and stay safe! :)


I am curious as to why you still use Windows 98, it sureley is a software/hardware compatibility nightmare.

RegJump() - Jump to registry path in Regedit

HoverScroll() - HoverScroll() - Scroll controls without focus


Scoox
  • Members
  • 194 posts
  • Last active: Jun 09 2017 03:34 AM
  • Joined: 28 Nov 2010
InternetFileRead() seems highly customizable but the code is hard to read for some of us, and with hardly any comments I can't be asked to mess with it, so I ended up using UrlDownloadToFile. The fancy ASCII "InternetFileRead" header obviously looks very cool (or did until the recent forum update Posted Image) but more comments would have been even cooler.

RegJump() - Jump to registry path in Regedit

HoverScroll() - HoverScroll() - Scroll controls without focus


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

I read through this thread and I think I couldn't find any reference to my following question:

What is F=0x84000000 and what is its significance in the following line?:

InternetFileRead(ByRef V, URL="", RB=0, bSz=1024, DLP="DLP", F=0x84000000) {...


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

 

I read through this thread and I think I couldn't find any reference to my following question:

What is F=0x84000000 and what is its significance in the following line?:

InternetFileRead(ByRef V, URL="", RB=0, bSz=1024, DLP="DLP", F=0x84000000) {...

 

 

 

 

 

 

 

its mentioned in the first post:

 

"F : Flags. Default is INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE which makes sure file is not read from/written into cache."

 

and looking at the code, it looks like its used in the InternetOpenUrlA dllcall. so just google that



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

You may force download the file if you can guesstimate the file size:

URL := "http://www.pcidatabase.com/reports.php?type=csv"
If ( InternetFileRead( CSV, URL, [color=red]2**19 [/color] ) > 0 ) && !ErrorLevel ; 2**19 is 512K
  If VarZ_Save( CSV, "reports.csv" )
     Run Notepad Reports.csv


my calculator does show that 2^19 = 512kb
but when i use this value i can only download 256kb

i had to increase to 2**20 to download my full file

tedbalog
  • Members
  • 10 posts
  • Last active: Nov 12 2013 08:38 PM
  • Joined: 07 Feb 2012

Fixed code as you suggested.
Many thanks jballi.. :D

.. and I am truly sorry for the late reply.

 

 

Hi Skan -

 

This function is great, however I'm having the same troubles. I'm executing three downloads in a row, it runs the first one properly - skips the second - and runs the third properly. I'm using the version of the function which has QRL removed from the static line, to no avail.

 

Through debugging, the function stops here:

   Return 0 - ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) ) - 2

Any ideas for what I can do to fix it?



ricssoares
  • Members
  • 1 posts
  • Last active: Nov 22 2014 06:06 PM
  • Joined: 19 Nov 2014

InternetFileRead()

As the name suggests, this function reads a file from internet (passed to it as URL).
It is similar to AHK FileRead command in following ways:
1) Reads the content into Memory Variable
2) Can read the specified number of bytes from the leading part of the file.
3) Data retrieved will be in binary ( but to process it, we are on our own )
Parameters :

[*:2dhzuykb]V : Variable name passed as ByRef
[*:2dhzuykb]URL : A valid existing URL from which File will be read from
[*:2dhzuykb]RB : Requested Bytes. Pass 0 to read the whole file or request the number of bytes to read.
[*:2dhzuykb]bSz : Buffer Size. Default value is 1024 ( bytes ). File will be read in small chunks as specified with this parameter. You can increase it for faster downloads but should result in less responsive GUI.
[*:2dhzuykb]DLP : The dynamic function name of the function that will handle the "Download Progress". I have included one .. You can add more in the same script and call them as per your criteria. A simple one would look like:

DLPCE( WP=0, LP=0, MSG="" ) {
 Tooltip, Downloading : %WP% / %LP%
}
[*:2dhzuykb]F : Flags. Default is INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE which makes sure file is not read from/written into cache.


Return Value & ErrorLevel:

If there are no errors from API functions, the function will return the Bytes Read, which will be exactly equal to the Variable's capacity.
If Bytes Read is lesser than the File/Content Length or If Bytes Read is equal to Requested Bytes, AHK ErrorLevel will be set to 1
On an API error, the function will return a negative number which can interpreted as follows:

-1 Internet Connection Problem
-2 Internet Connection Problem
-4 Length of file could not be ascertained
-5 The above and one of the Internet handles could not closed
-6 The above one more of the Internet handles could not closed
-7 One of the Internet handles could not closed
-8 Both of the the Internet handles could not closed
The included dynamic function DLP() will display a progress-bar
in the right-bottom for the screen:

filereadinternet.png
[/list]

/*
[color=#808080]       ___       _                       _   _____ _ _      ____                _ [/color]
[color=#808080]      |_ _|_ __ | |_ ___ _ __ _ __   ___| |_|  ___(_) | ___|  _ \ ___  __ _  __| |[/color]
[color=#111111]       | || '_ \| __/ _ \ '__| '_ \ / _ \ __| |_  | | |/ _ \ |_) / _ \/ _` |/ _` |[/color]
[color=#111111]       | || | | | ||  __/ |  | | | |  __/ |_|  _| | | |  __/  _ <  __/ (_| | (_| |[/color]
[color=#808080]      |___|_| |_|\__\___|_|  |_| |_|\___|\__|_|   |_|_|\___|_| \_\___|\__,_|\__,_|[/color]

                              by [color=#9F009B]SKAN[/color] ( [color=#9F009B]Suresh Kumar A N[/color], [email protected] )
                                      [color=black]Created: 24-Jun-2009 | LastEdit: 15-Dec-2009[/color]
                       Forum Topic: www.autohotkey.com/forum/viewtopic.php?t=45718
           Included : [color=#F73D00]InternetFileRead()[/color], [color=#F73D00]DLP()[/color] Progress Bar, [color=#F73D00]VarZ_Save()[/color],Examples
      ____________________________________________________________________________
      Credit:

      [color=#9F009B]Olfen[/color] for his topics:

                          [color=#111111]DllCall: HttpQueryInfo - Get HTTP headers[/color]
                          - www.autohotkey.com/forum/topic10510.html
                          [color=#111111]UrlDownloadToVar()[/color]
                          - www.autohotkey.com/forum/topic10466.html
      [color=#9F009B]Lexikos[/color] for:
                          [color=#111111]For supporting this project with valuable info,
                          especially:[/color]

                          [color=#111111]code/method to support FTP read[/color]
                          - www.autohotkey.com/forum/viewtopic.php?p=277646#277646

                          [color=#111111]clarifying alternative parameter for proxy issues[/color]
                          - www.autohotkey.com/forum/viewtopic.php?p=279205#279205
                          - www.autohotkey.com/forum/viewtopic.php?p=279210#279210

      [color=#9F009B]jballi[/color] for fixing an important bug
                          - www.autohotkey.com/forum/viewtopic.php?p=496321#496321

      [color=#111111]Thanks to all the replies in Forum Topic which motivates me to perfect this.[/color]
*/

#SingleInstance Force

; Example 1: Download the leading 100 bytes of default HTML and extract a part of text.
URL := "[color=#2255FF]http://www.formyip.com/[/color]"
If ( [color=#F73D00]InternetFileRead([/color] IP, URL, 100, 100, "No-Progress" [color=#F73D00])[/color] > 0 )
  MsgBox, 64, Your External IP Address
        , % IP := SubStr( IP,SP:=InStr(IP,"My ip address ")+17,InStr(IP," ",0,SP+1)-SP )


; Example 2, Download a binary file ( AHK Script Decompiler ) and save it.
URL := "[color=#2255FF]http://www.autohotkey.com/download/Exe2Ahk.exe[/color]"
If ( [color=#F73D00]InternetFileRead([/color] binData, URL, False, 10240, "No-Progress" [color=#F73D00])[/color] > 0 && !ErrorLevel )
  If [color=#F73D00]VarZ_Save([/color] binData, A_ScriptDir "\Exe2Ahk.exe" [color=#F73D00])[/color]
     MsgBox, 64, AHK Script Compiler Downloaded and Saved, % A_ScriptDir "\Exe2Ahk.exe"


; Example 3, Download a FTP file: EditPlus 3.11 Evaluation Version (1 MB) and save it.
URL := "[color=#2255FF]ftp://ftp.editplus.com/epp311_en.exe[/color]"
If ( [color=#F73D00]InternetFileRead([/color] binData, URL [color=#F73D00])[/color] > 0 && !ErrorLevel )
    If [color=#F73D00]VarZ_Save([/color] binData, A_Temp "\epp311_en.exe" [color=#F73D00])[/color] {
         Sleep 500
         DLP( False ) ; or use Progress, off
         Run %A_Temp%\epp311_en.exe
       }

; AHK will automatically unload libraries on exit. If you are particular, here is a method
; to unload Wininet library without a handle.
DllCall( "[color=#B92300]FreeLibrary[/color]", UInt,DllCall( "[color=#B92300]GetModuleHandle[/color]", Str,"wininet.dll") )
Return ;                                                 [color=red]// end of auto-execute section //[/color]


[color=#F73D00]InternetFileRead([/color] ByRef V, URL="", RB=0, bSz=1024, DLP="DLP", F=0x84000000 [color=#F73D00])[/color] {
 Static LIB="WININET\", CL="00000000000000", N=""
 QRL := 16
 If ! DllCall( "[color=#B92300]GetModuleHandle[/color]", Str,"wininet.dll" )
      DllCall( "[color=#B92300]LoadLibrary[/color]", Str,"wininet.dll" )
 If ! hIO:=DllCall( LIB "[color=#B92300]InternetOpenA[/color]", Str,N, UInt,4, Str,N, Str,N, UInt,0 )
   Return -1
 If ! (( hIU:=DllCall( LIB "[color=#B92300]InternetOpenUrlA[/color]", UInt,hIO, Str,URL, Str,N, Int,0, UInt,F
                                                            , UInt,0 ) ) || ErrorLevel )
   Return 0 - ( !DllCall( LIB "[color=#B92300]InternetCloseHandle[/color]", UInt,hIO ) ) - 2
 If ! ( RB  )
 If ( SubStr(URL,1,4) = "ftp:" )
    CL := DllCall( LIB "[color=#B92300]FtpGetFileSize[/color]", UInt,hIU, UIntP,0 )
 Else If ! DllCall( LIB "[color=#B92300]HttpQueryInfoA[/color]", UInt,hIU, Int,5, Str,CL, UIntP,QRL, UInt,0 )
   Return 0 - ( !DllCall( LIB "[color=#B92300]InternetCloseHandle[/color]", UInt,hIU ) )
            - ( !DllCall( LIB "[color=#B92300]InternetCloseHandle[/color]", UInt,hIO ) ) - 4
 VarSetCapacity( V,64 ), VarSetCapacity( V,0 )
 SplitPath, URL, FN,,,, DN
 FN:=(FN ? FN : DN), CL:=(RB ? RB : CL), VarSetCapacity( V,CL,32 ), P:=&V,
 B:=(bSz>CL ? CL : bSz), TtlB:=0, LP := RB ? "Unknown" : CL,  %DLP%( True,CL,FN )
 Loop {
       If ( DllCall( LIB "[color=#B92300]InternetReadFile[/color]", UInt,hIU, UInt,P, UInt,B, UIntP,R ) && !R )
       Break
       P:=(P+R), TtlB:=(TtlB+R), RemB:=(CL-TtlB), B:=(RemB<B ? RemB : B), %DLP%( TtlB,LP )
       Sleep -1
 } TtlB<>CL ? VarSetCapacity( T,TtlB ) DllCall( "[color=#B92300]RtlMoveMemory[/color]", Str,T, Str,V, UInt,TtlB )
  . VarSetCapacity( V,0 ) . VarSetCapacity( V,TtlB,32 ) . DllCall( "[color=#B92300]RtlMoveMemory[/color]", Str,V
  , Str,T, UInt,TtlB ) . %DLP%( TtlB, TtlB ) : N
 If ( !DllCall( LIB "[color=#B92300]InternetCloseHandle[/color]", UInt,hIU ) )
  + ( !DllCall( LIB "[color=#B92300]InternetCloseHandle[/color]", UInt,hIO ) )
   Return -6
Return, VarSetCapacity(V)+((ErrorLevel:=(RB>0 && TtlB<RB)||(RB=0 && TtlB=CL) ? 0 : 1)<<64)
}
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; The following function is an add-on to provide "Download Progress" to InternetFileRead()
; InternetFileRead() calls DLP() dynamically, i.e., will not error-out if DLP() is missing
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[color=#F73D00]DLP([/color] WP=0, LP=0, Msg="" [color=#F73D00])[/color] {
 If ( WP=1 ) {
 SysGet, m, MonitorWorkArea, 1
 y:=(mBottom-46-2), x:=(mRight-370-2), VarSetCapacity( Size,16,0 )
 DllCall( "[color=#B92300]shlwapi.dll\StrFormatByteSize64A[/color]", Int64,LP, Str,Size, UInt,16 )
 Size := ( Size="0 bytes" ) ? N : "«" Size "»"
 Progress, CWE6E3E4 CT000020 CBF73D00 x%x% y%y% w370 h46 B1 FS8 WM700 WS400 FM8 ZH8 ZY3
         ,, %Msg%  %Size%, InternetFileRead(), Tahoma
 WinSet, Transparent, 210, InternetFileRead()
 } Progress,% (P:=Round(WP/LP*100)),% "Memory Download: " wp " / " lp " [ " P "`% ]"
 IfEqual,wP,0, Progress, Off
}
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; The following function is a part of: [color=#F73D00]VarZ 46L - Native Data Compression[/color]
; View topic : www.autohotkey.com/forum/viewtopic.php?t=45559
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[color=#F73D00]VarZ_Save([/color] byRef V, File="" [color=#F73D00])[/color] { ;   www.autohotkey.net/~Skan/wrapper/FileIO16/FileIO16.ahk
Return ( ( hFile :=  DllCall( "[color=#B92300]_lcreat[/color]", Str,File, UInt,0 ) ) > 0 )
                 ?   DllCall( "[color=#B92300]_lwrite[/color]", UInt,hFile, Str,V, UInt,VarSetCapacity(V) )
                 + ( DllCall( "[color=#B92300]_lclose[/color]", UInt,hFile ) << 64 ) : 0
}

I got an error in this line: InternetFileRead( ByRef V, URL="", RB=0, bSz=1024, DLP="DLP", F=0x84000000 ) {

This line does not contain a recognized action.

 

Win8.1, x64, AHK v. 1.1.16.5

 

Please, anyone can help me?



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

I went to the first page and first post of this thread.

I copied the contents of the listing at the bottom of the post.

I removed ALL the [color] tags for example  ---> [color=#808080]   ---> [/color]

 

I disabled example #3 by adding semicolon ;  to the beginning of each line of the example

 

I saved the script as    InternetFileRead.ahk making sure the file extension was AHK

 

when I 2x click the file in windows explorer, it ran and worked as I expected. giving me my IP and downloaded the file

 

 

if I wanted to use this file, I would leave it as is and write my own separate script with something like the example show.

 

I work include the line #include InternetFileRead.ahk

 

 

 

Have you done all these steps?

If not, what have you done?   

Be specific.

 



3rror
  • Members
  • 18 posts
  • Last active:
  • Joined: 29 May 2013

I could only get it to work by removing the ending "A"s from the DLLs, eg. InternetOpenA -> InternetOpen

I think this may be necessary if using unicode

 

Edit: I just noticed hughman did a unicode version a page back.



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

This doesn't seem to be working anymore. Could anyone post a working script?

; http://www.autohotkey.com/board/topic/42096-function-internetfileread-aka-urldownloadtovar/

#SingleInstance Force

/*
; Example 1: Download the leading 100 bytes of default HTML and extract a part of text.
URL := "http://www.formyip.com/"
If ( InternetFileRead( IP, URL, 100, 100, "No-Progress" ) > 0 )
  MsgBox, 64, Your External IP Address
        , % IP := SubStr( IP,SP:=InStr(IP,"My ip address ")+17,InStr(IP," ",0,SP+1)-SP )


; Example 2, Download a binary file ( AHK Script Decompiler ) and save it.
;URL := "http://www.autohotkey.com/download/Exe2Ahk.exe" ; Disabled
If ( InternetFileRead( binData, URL, False, 10240, "No-Progress" ) > 0 && !ErrorLevel )
  If VarZ_Save( binData, A_ScriptDir "\Exe2Ahk.exe" )
     MsgBox, 64, AHK Script Compiler Downloaded and Saved, % A_ScriptDir "\Exe2Ahk.exe"


; Example 3, Download a FTP file: EditPlus 3.11 Evaluation Version (1 MB) and save it.
;URL := "ftp://ftp.editplus.com/epp311_en.exe" ; Disabled
If ( InternetFileRead( binData, URL ) > 0 && !ErrorLevel )
    If VarZ_Save( binData, A_Temp "\epp311_en.exe" ) {
         Sleep 500
         DLP( False ) ; Or use Progress, off
         Run %A_Temp%\epp311_en.exe
       }

; AHK will automatically unload libraries on exit. If you are particular, here is a method
; to unload Wininet library without a handle.
DllCall( "FreeLibrary", UInt,DllCall( "GetModuleHandle", Str,"wininet.dll") )
Return ; // End of auto-execute section //
*/

InternetFileRead( ByRef V, URL="", RB=0, bSz=1024, DLP="DLP", F=0x84000000 ) {
 Static LIB="WININET\", CL="00000000000000", N=""
 QRL := 16
 If ! DllCall( "GetModuleHandle", Str,"wininet.dll" )
      DllCall( "LoadLibrary", Str,"wininet.dll" )
 If ! hIO:=DllCall( LIB "InternetOpenA", Str,N, UInt,4, Str,N, Str,N, UInt,0 )
   Return -1
 If ! (( hIU:=DllCall( LIB "InternetOpenUrlA", UInt,hIO, Str,URL, Str,N, Int,0, UInt,F
                                                            , UInt,0 ) ) || ErrorLevel )
   Return 0 - ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) ) - 2
 If ! ( RB  )
 If ( SubStr(URL,1,4) = "ftp:" )
    CL := DllCall( LIB "FtpGetFileSize", UInt,hIU, UIntP,0 )
 Else If ! DllCall( LIB "HttpQueryInfoA", UInt,hIU, Int,5, Str,CL, UIntP,QRL, UInt,0 )
   Return 0 - ( !DllCall( LIB "InternetCloseHandle", UInt,hIU ) )
            - ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) ) - 4
 VarSetCapacity( V,64 ), VarSetCapacity( V,0 )
 SplitPath, URL, FN,,,, DN
 FN:=(FN ? FN : DN), CL:=(RB ? RB : CL), VarSetCapacity( V,CL,32 ), P:=&V,
 B:=(bSz>CL ? CL : bSz), TtlB:=0, LP := RB ? "Unknown" : CL,  %DLP%( True,CL,FN )
 Loop {
       If ( DllCall( LIB "InternetReadFile", UInt,hIU, UInt,P, UInt,B, UIntP,R ) && !R )
       Break
       P:=(P+R), TtlB:=(TtlB+R), RemB:=(CL-TtlB), B:=(RemB<B ? RemB : B), %DLP%( TtlB,LP )
       Sleep -1
 } TtlB<>CL ? VarSetCapacity( T,TtlB ) DllCall( "RtlMoveMemory", Str,T, Str,V, UInt,TtlB )
  . VarSetCapacity( V,0 ) . VarSetCapacity( V,TtlB,32 ) . DllCall( "RtlMoveMemory", Str,V
  , Str,T, UInt,TtlB ) . %DLP%( TtlB, TtlB ) : N
 If ( !DllCall( LIB "InternetCloseHandle", UInt,hIU ) )
  + ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) )
   Return -6
Return, VarSetCapacity(V)+((ErrorLevel:=(RB>0 && TtlB<RB)||(RB=0 && TtlB=CL) ? 0 : 1)<<64)
}
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; The following function is an add-on to provide "Download Progress" to InternetFileRead()
; InternetFileRead() calls DLP() dynamically; i.e., will not error-out if DLP() is missing
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

DLP( WP=0, LP=0, Msg="" ) {
 If ( WP=1 ) {
 SysGet, m, MonitorWorkArea, 1
 y:=(mBottom-46-2), x:=(mRight-370-2), VarSetCapacity( Size,16,0 )
 DllCall( "shlwapi.dll\StrFormatByteSize64A", Int64,LP, Str,Size, UInt,16 )
 Size := ( Size="0 bytes" ) ? N : "«" Size "»"
 Progress, CWE6E3E4 CT000020 CBF73D00 x%x% y%y% w370 h46 B1 FS8 WM700 WS400 FM8 ZH8 ZY3
         ,, %Msg%  %Size%, InternetFileRead(), Tahoma
 WinSet, Transparent, 210, InternetFileRead()
 } Progress,% (P:=Round(WP/LP*100)),% "Memory Download: " wp " / " lp " [ " P "`% ]"
 IfEqual,wP,0, Progress, Off
}
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; The following function is a part of: VarZ 46L - Native Data Compression
; View topic : www.autohotkey.com/forum/viewtopic.php?t=45559
;  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

VarZ_Save( byRef V, File="" ) { ;   www.autohotkey.net/~Skan/wrapper/FileIO16/FileIO16.ahk
Return ( ( hFile :=  DllCall( "_lcreat", Str,File, UInt,0 ) ) > 0 )
                 ?   DllCall( "_lwrite", UInt,hFile, Str,V, UInt,VarSetCapacity(V) )
                 + ( DllCall( "_lclose", UInt,hFile ) << 64 ) : 0
}

/*
username=arian.suresh
password=********
url=https://%username%:%password%@mail.google.com/mail/feed/atom/
*/
/*
I need to download only part of file; i.e., very first 350 bytes of file.

Here is an example:
InternetFileRead( Data, "http://www.autohotkey.com/forum/rss.php" , 350, 350, "" )
MsgBox, 0, % StrLen(Data), % Data
*/