All pastes #637136 Raw Edit

Something

public text v1 · immutable
#637136 ·published 2007-07-28 16:13 UTC
rendered paste body
public class SingleInstanceApplication : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
{
	private SingleInstanceApplication() { base.IsSingleInstance = true; }
	public static void Run( System.Windows.Forms.Form f, Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventHandler startupHandler )
	{
		SingleInstanceApplication app = new SingleInstanceApplication();
		app.MainForm = f;
		app.StartupNextInstance += startupHandler;
		app.Run(Environment.GetCommandLineArgs());
	}
}


static class Program
{
    [STAThread]
    static void Main()
    { 
        Application.EnableVisualStyles();
        SingleInstanceApplication.Run(new Form1(), 
            StartupNextInstanceHandler);
    }

    static void StartupNextInstanceHandler(
        object sender, StartupNextInstanceEventArgs e)
    {
        // do whatever you want here with e.CommandLine...
    }
}