remixgame | Voici le module
Code :
- Option Explicit
- Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
- Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
- Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
- Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
- Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
- Public Const INTERNET_OPEN_TYPE_DIRECT = 1
- Public Const INTERNET_OPEN_TYPE_PROXY = 3
- Public Const scUserAgent = "VB OpenUrl"
- Public Const INTERNET_FLAG_RELOAD = &H80000000
- Sub Download(URL As String, SaveAs As String)
- Dim hOpen As Long
- Dim hOpenUrl As Long
- Dim bDoLoop As Boolean
- Dim bRet As Boolean
- Dim sReadBuffer As String * 2048
- Dim lNumberOfBytesRead As Long
- Dim sBuffer As String
- hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
- hOpenUrl = InternetOpenUrl(hOpen, URL, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
- bDoLoop = True
- While bDoLoop
- sReadBuffer = vbNullString
- bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
- sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
- If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
-
-
- Wend
-
- Open SaveAs For Binary Access Write As #1
- Put #1, , sBuffer
- Close #1
-
- If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)
- If hOpen <> 0 Then InternetCloseHandle (hOpen)
- End Sub
|
Quand j'utilise ce module en l'appelant par Code :
- call download ("www.grosficheir.com/grosficheir.Exe","c:\gff.exe" )
|
par exemple Le programme ne va plus répondre (on ne peux plus bouger la fenetre ni appuyer sur les boutons il plante quoi )tant que le fichier ne sera pas télécharger quand il a fini de le télécharger tout redevient normal
POURQUOI ?
S'il vous plait aidez moi
|