PostInstallForm.cs from Oscill8 at Krugle
Show PostInstallForm.cs syntax highlighted
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace PostInstall
{
public partial class PostInstallForm : Form
{
// a little helper...
delegate void SetTextCallback(string text);
// need to store directory
private string baseDir;
// base possible basedir arg
public PostInstallForm(string[] args)
{
InitializeComponent();
// get dir
baseDir = args.Length > 0 ? args[0] + "\\" : "";
}
// start thread to do work
private void PostInstallForm_Load(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(this.ThreadProc));
t.Start();
}
private void ThreadProc()
{
// flash text
this.SetText("oscill8 -sbwregister");
Application.DoEvents();
ProcessStartInfo psi = new ProcessStartInfo(baseDir + "oscill8", "-sbwregister");
psi.WindowStyle = ProcessWindowStyle.Hidden;
try { Process.Start(psi); }
catch(Exception e)
{
MessageBox.Show("Unable to register oscill8 with SBW: "
+ e.Message + "\n[" + baseDir + "oscill8]", "Error", MessageBoxButtons.OK);
}
// flash text
this.SetText("o8core -sbwregister");
Application.DoEvents();
psi = new ProcessStartInfo(baseDir + "o8core", "-sbwregister");
psi.WindowStyle = ProcessWindowStyle.Hidden;
try { Process.Start(psi); }
catch(Exception e)
{
MessageBox.Show("Unable to register o8core with SBW: "
+ e.Message + "\n[" + baseDir + "o8core]", "Error", MessageBoxButtons.OK);
}
// kill it
Application.Exit();
}
private void SetText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (label.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
label.Text = text;
}
}
}
}
See more files for this project here