Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / WPF

C# .NET Autoupdate Application Launcher

Rate me:
Please Sign up or sign in to vote.
4.53/5 (17 votes)
8 Dec 2010CPOL13 min read 203.1K   17.3K   152  
Easily lets you post updated versions of your application for remote clients to download without running another setup.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Microsoft.Shell;

namespace ArticleAutoUpdater
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application, ISingleInstanceApp
	{
		private const string Unique = "C13432B2-A436-4EEE-AFE2-E762C87094B1";

		private void Application_Startup(object sender, StartupEventArgs e)
		{
			new MainWindow().Show();
		}

		[STAThread]
		public static void Main()
		{
			if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
			{
				var application = new App();

				application.InitializeComponent();
				application.Run();

				// Allow single instance code to perform cleanup operations
				SingleInstance<App>.Cleanup();
			}
			else
			{
				MessageBox.Show("There is another instance of the application running.");
			}
		}

		#region ISingleInstanceApp Members

		bool Microsoft.Shell.ISingleInstanceApp.SignalExternalCommandLineArgs(IList<string> args)
		{
			// We don't have any command line args for this app!
			return true;
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions