dcsimg
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 27, 2004

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
Thanks for your registration, follow us on our social networks to keep up-to-date