rendered paste bodypublic 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...
}
}