Hi programmer07, thanks for the tip, I think you understand my problem good. But I'm working with vs2005 and I can't find the button you talk about. I'll keep looking for it. Thanks a lot.
: Hi programmer07, thanks for the tip, I think you understand my : problem good. But I'm working with vs2005 and I can't find the : button you talk about. I'll keep looking for it. Thanks a lot.
This is an old post, but in case anyone is wondering this should go in the Program.cs Main() method. This works when running the application on a local workstation and via terminal services. [code] using System.Diagnostics; Process proc = Process.GetCurrentProcess(); string name = proc.ProcessName; int count = 0; foreach(Process p in Process.GetProcessesByName(name)) { if(p.SessionId == p.SessionId) count++; }
Comments
Right-click your application in Solution Explorer. You'll see an option (Checkbox) to Make a Single Instance Application. That should do it.
: problem good. But I'm working with vs2005 and I can't find the
: button you talk about. I'll keep looking for it. Thanks a lot.
This is an old post, but in case anyone is wondering this should go in the Program.cs Main() method. This works when running the application on a local workstation and via terminal services.
[code]
using System.Diagnostics;
Process proc = Process.GetCurrentProcess();
string name = proc.ProcessName;
int count = 0;
foreach(Process p in Process.GetProcessesByName(name))
{
if(p.SessionId == p.SessionId)
count++;
}
if(count < 1)
{
//start application
Application.run(new MainForm());
}
[/code]