Link to home
Start Free TrialLog in
Avatar of samsonite1023
samsonite1023

asked on

Upgradable Application

Hello.  I'm about to start a project.  I'd like it to be able to have the application check for an update and download appropiately.  I can handle the queries to a server and the downloading part, I'm just unsure how to impliment it.

Here's what I have.  

User hits "upgrade" (or app does it automatically).
App sends request to my server, or loads a simple webpage (ie www.bla.com?ver=1)
Server sends back a 0 if no updates, or the location to download the upgrade if it is out of date.
App downloads the file.
Then what?

How can an application upgrade itself while it is running?  Do I need to use DLL's?

If someone could point me in the right direction or give me an idea of how to do this, I'd be very grateful.
Avatar of dmarco
dmarco
Flag of Italy image

Hi samsonite1023,

To open a webpage from a VB application you have to add a Wbebrowser control to your project : click on project > components and add "Microsoft Internet Controls" (shdocvw.dll) to your program.
Add also "Microsoft Internet Transfer Control 6.0 " (MSInet.ocx).

To load a webpage :

WebBrowser1.Navigate "http:\\www.bla.com"

>>Server sends back a 0 if no updates, or the location to download the upgrade if it is out of date.<<

What do you mean exactly ? Can you explain better what do you want to do.

However to load a file from your vb program :

Dim b() As Byte  ' download a file in binary format ( e.g. an .exe file, .zip, .mdb, etc.....)'
Dim strURL As String
' Imposta strURL su un indirizzo valido.
strURL = "http://www.bla.com/myfile.exe"
b() = Inet1.OpenURL(strURL, icByteArray)

Open "C:\Temp\myfile.exe" For Binary Access _ Write As #1   ' write the file on your hard disk'
Put #1, , b()
Close #1

If you want to dowload a text file or a simple text webpage :

Text1.Text = Inet1.OpenURL("http://www.bla.com")  'this code fills your text box with the html code + the text of your webpage. Then you can parse and save the text in a text file'

Text1.Text = Inet1.OpenURL("http://www.bla.com/disclaimer.txt")  'the text box is filled with your file text and you can save it '

Avatar of Éric Moreau
Avatar of samsonite1023
samsonite1023

ASKER

I think you misunderstood the question.

I already know how to do all of that.  But I need to know how to upgrade the application to a newer version.

Basically, I want to know how to have a live update feature for whatever programs I make.  

I know how to check for the update and download it (if its necessary), but I *DO NOT* know what to do after that.  Nor do I know what to code in the actual update.

I hope you can understand my question.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
After download the new version exe, you call the setup of the new exe with shellexecute, and also exit your upgrade form/session at the same time, the installation will continue to finish.

fyi: shellexecute is an API that run another application.
   : you may need to exit current running instance of same program before installation

Regards,
~ fantasy ~
Points to emoreau