Click here to Skip to main content
15,893,508 members
Articles / Mobile Apps / Windows Mobile

ToDoList Viewer - PocketPC Viewer for .dan.g's ToDoList

Rate me:
Please Sign up or sign in to vote.
4.14/5 (26 votes)
9 Aug 2004CPOL4 min read 144.7K   455   50  
A read only viewer of the ToDoList XML for the PocketPC.
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

using System.Windows.Forms;
using System.Reflection;
using System.IO;
using Microsoft.Win32;
using System.Diagnostics;

namespace CustomInstaller
{
	/// <summary>
	/// Summary description for Installer.
	/// </summary>
	[RunInstaller(true)]
	public class Installer : System.Configuration.Install.Installer
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Installer()
		{
			// This call is required by the Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitializeComponent call
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}


		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			// 
			// Installer
			// 
			this.AfterUninstall += new System.Configuration.Install.InstallEventHandler(this.Installer_AfterUninstall);
			this.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.Installer_AfterInstall);

		}
		#endregion

		private void Installer_AfterInstall(object sender, System.Configuration.Install.InstallEventArgs e)
		{
			// get fullpath to .ini file
			string arg = Path.Combine(
				Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
				"Setup.ini");
			
			// run WinCE App Manager to install .cab file on device
			RunAppManager(arg);
		}

		private void Installer_AfterUninstall(object sender, System.Configuration.Install.InstallEventArgs e)
		{
			// run app manager in uninstall mode (without any arguments)
			RunAppManager(null);
		}

		private void RunAppManager(string arg)
		{
			// get path to the app manager
			const string RegPath = @"Software\Microsoft\Windows\" + 
					  @"CurrentVersion\App Paths\CEAppMgr.exe";
			RegistryKey key = Registry.LocalMachine.OpenSubKey(RegPath);					
			string appManager = key.GetValue("") as string;
			
			if (appManager != null)
			{
				// launch the app
				Process.Start(
					string.Format("\"{0}\"", appManager), 
					(arg == null) ? "" : string.Format("\"{0}\"", arg));
			}
			else
			{
				// could not locate app manager
				MessageBox.Show("Could not launch the WinCE Application Manager.");
			}
		}
	}
}

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
Team Leader
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