News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Internet function?

Started by Farabi, July 24, 2005, 04:14:28 AM

Previous topic - Next topic

Farabi

I have upload an exe on a website, and I want my program auto download it after promt the auto update to the user, how to do it and what API I must use?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ctt

Look at this example here.

Good luck!

Faiseur

You can simplify your work with API UrlDownloadToFile (see in example 12 in Masm package) or using Wininet :


GetWinInetFile PROTO :DWORD,:DWORD


.code

; Success == 1, 0 == error
GetWinInetFile PROC fUrl,fSav:DWORD
LOCAL hUrl,fHand,bwrite,szBuffer,hSession: DWORD
LOCAL Buffer[1024]: BYTE

mov hSession, FUNC (InternetOpen,chr$('toto'),INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,NULL)
.if hSession != 0
    mov hUrl,FUNC (InternetOpenUrl,hSession,fUrl,NULL,NULL,NULL,NULL)
    .if hUrl != 0
        mov fHand, FUNC (CreateFile,fSav,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0)
        .if fHand != INVALID_HANDLE_VALUE
            inc szBuffer
            .WHILE szBuffer != 0
               invoke InternetReadFile,hUrl,addr Buffer,sizeof Buffer,addr szBuffer
               invoke WriteFile,fHand,addr Buffer,szBuffer,ADDR bwrite,NULL
            .ENDW
            invoke CloseHandle,fHand
            invoke InternetCloseHandle,hUrl
            invoke InternetCloseHandle,hSession
        .endif         
    .endif
.endif
ret
GetWinInetFile ENDP
French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"