Hello!

As some people have asked me, here?s the original MASM source by Ates:


include \MASM32\INCLUDE\wininet.inc
includelib \MASM32\LIB\wininet.lib

.data
fileUrl db "http://delphi.about.com/library/forminbpl.zip",0
fileSave db "saved.zip",0
msgOk db "Downloaded Success!",0
msgErr db "Download Failed!",0
mcap db "Result",0

.data?
AppName db 127 dup(?)
fHand dd ?
bwrite dd ?

.code
GetInetFile proc
LOCAL Buffer[1024]: BYTE
LOCAL hSession: DWORD
LOCAL hUrl: DWORD
LOCAL Bufferlen: DWORD
invoke GetModuleFileName, hInstance, addr AppName, sizeof AppName
invoke InternetOpen, addr AppName, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL
mov hSession, eax
.if hSession == INVALID_HANDLE_VALUE
mov eax, FALSE
ret
.endif
invoke InternetOpenUrl, hSession, addr fileUrl, NULL, NULL, NULL, NULL
mov hUrl, eax
.if hUrl == INVALID_HANDLE_VALUE
mov eax, FALSE
ret
.endif
invoke CreateFile, addr fileSave, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ,\
NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
mov fHand, eax
.if fHand == INVALID_HANDLE_VALUE
mov eax, FALSE
ret
.endif
invoke SetFilePointer, fHand, NULL, NULL, FILE_BEGIN
download:
invoke InternetReadFile, hUrl, addr Buffer, sizeof Buffer, addr Bufferlen
.if Bufferlen != 0
invoke WriteFile, fHand, addr Buffer, Bufferlen, ADDR bwrite, NULL
jmp download
.endif
invoke CloseHandle, fHand
invoke InternetCloseHandle, hUrl
invoke InternetCloseHandle, hSession
mov eax, TRUE
ret
GetInetFile endp

; Call this like...
invoke GetInetFile
.if eax == TRUE
invoke MessageBox, hWin, addr msgOk, addr mcap, MB_OK
.else
invoke MessageBox, hWin, addr msgErr, addr mcap, MB_OK
.endif
Posted on 2002-08-12 11:52:02 by slop
when i run this prog i see hourglass ,why?
how to avoid that?

and the process do not quit properly ,i must to kill it:)
Posted on 2002-08-30 14:01:20 by Cozycactus
The hourglass is probably set by WinInet library (kind of silly if you ask me to do that). Where is the exit code in your program? I don't see ExitProcess or any such.
Posted on 2002-08-30 16:24:30 by comrade
Liste guys: THIS IS JUST A SNIPPET,
not a working veresion, you have to include all the functionalities and interfaces and stuuf that you want, that's why there's no ExitProcess or nothing.
If you feel like seeing a working tiny example of this go to the FASM version ;)
Posted on 2002-09-02 12:04:10 by slop