Results 1 to 5 of 5

Thread: A program that updates itself

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004

    A program that updates itself

    dear all
    i am working on VB 5 and i want to make a program that updates itself automatically from the internet, in order to do so, i need to know how to make that program download a file from a site (that is the zip containing the new version)
    i'd be glad to hear from you about that, specially with code, i hope you don't use code that needs dlls or ocxs, just APIS and natural coding
    thanks and all the best

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    define what you mean by:
    updates itself

  3. #3
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Saskatoon, SK
    I think he means, you know for example when your virus scanner connects to its company's server and checks for udpates...if there is one, then it downloads and installs.

    Now, depends what you are updating, when it comes to VB...You are probably updating the exe, which means you might as well forget about it and just tell the user to update himself when the time comes.

    You can use a function which compares the size of one file to another. Have the server send back the size of the exe and compare it with the running exe...If they are the same, then version is up to date, if they are different then tell the user to download one.

    It aint hard to download files off the net using winsock, but it is hard to write your own unzipping routines.

    If you want actually code, I'll post some, but it will be general, and you must ask what you want code for...Do not ask me to code the entire project, just examples.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    The 19th Hole
    To download the updated file you can use the code below. HTH

    VB Code:
    1. Option Explicit
    2. Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    3.     "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
    4.     ByVal szFileName As String, ByVal dwReserved As Long, _
    5.     ByVal lpfnCB As Long) As Long
    6. Private Sub Form_Load()
    7. Dim url As String
    8. Dim localFileName As String
    9. Dim filedownload As Long
    10. url = "" 'URL of update file
    11. localFileName = App.Path & "\" 'Location where to download file
    13. filedownload = URLDownloadToFile(0, url, localFileName, 0, 0) 'Download file
    15. End Sub

  5. #5
    Hyperactive Member
    Join Date
    Sep 2004
    You can do this but you need 2 executables. One the actual program and the other an installer.

    Use the code listed above to download the update files. Call the installer program with the update files as a parameter and close the main program.

    The installer is then free to update the main program, restart it and then close itself.


    Now do NOT be using this to autoload spyware on peoples machines.

    The Mav

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width