VB icon

Software Updater

Email
Submitted on: 1/8/2015 8:34:00 AM
By: michael coder (from psc cd)  
Level: Intermediate
User Rating: By 3 Users
Compatibility: C++ (general), Microsoft Visual C++
Views: 537
 
     With this code you can distribute software over the internet and if you ever need to update your programme you don't need to make everyone download the entire programme again or let some users use the outdated software but can simple update the version file to 2 for example and have everyone download the new update. You need to make sure that the direct download link to your programme is always the same or else you would need to update the link for your programme every time there would be an update.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Software Updater
//**************************************
#include <windows.h>
#include <iostream>
using namespace std;
//project must be linked to: urlmon.lib
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Software Updater
// Description:With this code you can distribute software over the internet and if you ever need to update your programme you don't need to make everyone download the entire programme again or let some users use the outdated software but can simple update the version file to 2 for example and have everyone download the new update. 
You need to make sure that the direct download link to your programme is always the same or else you would need to update the link for your programme every time there would be an update.
// By: michael coder (from psc cd)
//
// Assumes:How the code works:
Downloads a file from the internet e.g. a text file with a version number e.g. 1
opens the file and saves the content of the downloaded file and checks if its the same value of the current programme. If it is you can carry on using the programme however if not you are presented with a menu where you can chose to visit the download page or directly download the files or exit.
//**************************************

#include <windows.h>
#include <iostream>
using namespace std;
bool updated=false;
void menu (){
	int option;
	cout<<"Update Options\n";
	cout<<"1) Visit download page\n";
	cout<<"2) Automatically download the latest file version\n";
	cout<<"3) Exit\n";
	cout<<">>";
	cin>>option;
	switch(option)
	{
case 1:
		ShellExecute(NULL, "open", "Download page link" , NULL, NULL, SW_SHOWNORMAL);
exit(1);
		break;
case 2:
		URLDownloadToFile (NULL, "direct download link to your programme", "name of programme e.g. software.exe", 0, NULL); 
		exit(1);
		case 3:
		exit(1);
	}
}
int main (){
	cout<<"Checking for newer versions...\n";
	URLDownloadToFile (NULL, "download link to a file e.g. Version.txt", "name of file", 0, NULL); 
	FILE *ptr;
	int ch;
	ptr = fopen("The name your named it","r");
	cout<<"You are using version ";
	if(ptr != NULL){
		ch=fgetc(ptr);
		putchar(ch);
		fclose(ptr);
	}
	int ch1=ch-48;
	if (ch1==1){ /*change the value of 1 to the newest versions number*/
		cout<<"\nYou already have the newest version\n";
		updated=true;
	}
	else{
		cout<<"\nYour software is out-dated and needs updating...\n";
		menu ();
	}
	if (updated=true){
		cout<<"Now that this programme is updated you can use it\n";
		/*add any programmes code in here*/
	}
	system("PAUSE");
	return 1;
}
/*Good luck*/


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.