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