How do I integrate the Advanced Updater with my C# application?
Sample code on how to integrate the updater with a C# application.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Threading; using System.IO; namespace UpdaterExampleCSharp { /** * Sample code for using the Advanced Updater from C# applications. * * Note: For this sample code to work you must have the updater.exe and updater.ini * beside the C# applications main exe. * * @author Advanced Installer team * */ public partial class Form1 : Form { public Form1() { InitializeComponent(); // Start the thread that will launch the updater in silent mode with 10 second delay. Thread thread = new Thread(new ThreadStart(StartSilent)); thread.Start(); // Compute the updater.exe path relative to the application main module path updaterModulePath = Path.Combine(Application.StartupPath, "updater.exe"); } private static String updaterModulePath; private void FileClose_Click(object sender, EventArgs e) { this.Close(); } /** * This handler should be associated with a menu item that launches the * updater's configuration dialog. */ private void OptionsAutoUpdaters_Click(object sender, EventArgs e) { Process process = Process.Start(updaterModulePath, "/configure"); process.Close(); } /** * This handler should be associated with a menu item that launches the * updater in check now mode (usually from Help submenu) */ private void HelpCheckForUpdates_Click(object sender, EventArgs e) { Process process = Process.Start(updaterModulePath, "/checknow"); process.Close(); } private static void StartSilent() { Thread.Sleep(10000); Process process = Process.Start(updaterModulePath, "/silent"); process.Close(); } } } ........
The above code covers only the event handlers that should be implemented from inside your application.
Here is the main class that will call the above code.
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace UpdaterExampleCSharp { static class Program { /// The main entry point for the application. [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }