.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How run one instance of .exe file in my machine....

Posted By: susant     Posted Date: December 30, 2008    Points:2   Category :C#
I want to open only one instance of an application (.exe) in my Machine, what should i do?

C# + Windows application...

what will be the code?? or which properties i have to set??

Author: Rahul             
Posted Date: December 30, 2008     Points: 5   

You can use mutex concept to check the instance of the application running or not. Just modyfy the Main Method of the form like this and see

static void Main()
bool checkApps;

Mutex mutex = new System.Threading.Mutex(true, "YourApplicationName", out checkApps);
if (!checkApps)
MessageBox.Show("Application is already running.");

Application.Run(new Form1());

Author: susant             
Posted Date: December 30, 2008     Points: 5   

Hi rahul

u can in this way...

static void Main()

Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1)

Application.Run(new EaseInventory.Interfaces.frmLogOn());


But how to Activate my current running process bcz my application is in minimize mode in system tray.. so how to make it maxiize when the user again click on shortcut...?

Author: Rahul             
Posted Date: December 30, 2008     Points: 5   

Hi try this link to restore windows application


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend