 ) provenant de son Youtube Downloader, il permet de connaître la taille du fichier à télécharger.
 ) provenant de son Youtube Downloader, il permet de connaître la taille du fichier à télécharger.Quand je test ce code chez moi il n'y a pas de problème, le message requester m'affiche bien la taille en Ko du fichier, cependant chez certaines personnes la taille renvoyée est de 0.
Une des personnes utilise Windows XP sp2 comme moi, je ne vois pas d'où vient le problème, quelqu'un pourrait m'aider ? Merci.
Code : Tout sélectionner
Procedure Taille()
  ;Calcule de la taille du fichier à télécharger
  DownloadURL.s = "http://www.purebasic.com/download/PureBasic_Demo.exe" ;adresse de telechargement
    
  Protected hInet, hURL, Bytes
  Protected BufferLength = 2048, Buffer.s = Space(BufferLength) 
    
  Protected Url.s      = DownloadURL.s 
  Protected Filename.s = DownloadFilename.s 
  Protected File
  Protected CurrentSize.f, PreviousSize.f, FileSize.f, time, BytesPerSecond
  Protected Domain.s, String.s, i, BufferLengthWas = BufferLength
  Protected hInetCon, hHttpOpenRequest, iretval 
  
  hInet = InternetOpen_("Downloader",0,0,0,0) 
  hURL  = InternetOpenUrl_(hInet,Url.s,0,0,$80000000,0) 
    
  Domain.s  = StringField(Url.s,3,"/") 
  hInetCon = InternetConnect_(hInet,Domain.s,80,#Null,#Null,3,0,0) 
  If hInetCon 
    hHttpOpenRequest = HttpOpenRequest_(hInetCon,"HEAD",ReplaceString(Url.s,"http://"+Domain.s+"/",""),#Null,#Null,0,$80000000,0) 
    If hHttpOpenRequest 
      iretval = HttpSendRequest_(hHttpOpenRequest,#Null,0,0,0) 
      If iretval 
        HttpQueryInfo_(hHttpOpenRequest,19,@Buffer.s,@BufferLength,0) ;changes the buffer length 
        String.s = PeekS(@Buffer.s,BufferLength): BufferLength = BufferLengthWas 
        If Trim(String.s) = "200" 
          HttpQueryInfo_(hHttpOpenRequest,22,@Buffer.s,@BufferLength,0) 
          String.s = PeekS(@Buffer.s,BufferLength): BufferLength = BufferLengthWas 
          If FindString(String.s,"Content-Length:",1) 
            i = FindString(String.s,"Content-Length:",1) + Len("Content-Length:") 
            String.s = Mid(String.s,i,Len(String.s)-i) 
            FileSize = Val(Trim(String.s))/1024
          EndIf 
        EndIf 
      EndIf 
    EndIf 
  EndIf
    
  MessageRequester("Taille", Str(FileSize))
EndProcedure
taille()
End
 
 
