Functions > Network >


InetClose

Ferme un handle retourn� par InetGet().

InetClose ( handle )

Param�tre

handle Le handle retourn� par InetGet().

Valeur de retour

True: Le handle a �t� trouv� et ferm�.
False: Sinon.

Remarques

Les handles d'InetGet() doivent �tre ferm�s sinon, vous aurez une fuite de ressources.

En fermant le handle d'un t�l�chargement en cours, vous annulerez le t�l�chargement.

En relation

InetGet

Exemple

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Enregistre le fichier t�l�charg� dans le dossier temporaire.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; T�l�charge le fichier en arri�re-plan avec l'option choisie de "forcer le chargement du site distant."
    Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Attend la fin du t�l�chargement en v�rifiant si la valeur du 2nd index de InetGetInfo retourne True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; R�cup�re le nombre total d'octets re�us et la taille du fichier.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Ferme le handle retourn� par InetGet.
    InetClose($hDownload)

    ; Affiche les d�tails sur le nombre total d'octets lus et la taille du fichier.
    MsgBox($MB_SYSTEMMODAL, "", "Taille totale: " & $iBytesSize & @CRLF & _
            "Taille totale du fichier: " & $iFileSize)

    ; Supprime le fichier.
    FileDelete($sFilePath)
EndFunc   ;==>Example