Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C#
Expertise: Intermediate
Oct 26, 2004

Restrict Users to Launching Only One Instance of an Application

Use this code to make sure that users can only launch one instance of an application.

static void Main() 
{
	Process ThisProcess = Process.GetCurrentProcess();

	Process [] AllProcesses = Process.GetProcessesByName(ThisProcess.ProcessName);

	if (AllProcesses.Length > 1)
	{
		MessageBox.Show(ThisProcess.ProcessName + " is already running",
ThisProcess.ProcessName, MessageBoxButtons.OK, MessageBoxIcon.Error);
	}
	else
	{
		Application.Run(new MainForm());
	}
}
Vimal Kanth
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap