المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Is there a terminal services friendly way of writing this code?



C# Programming
08-21-2009, 02:40 AM
I am wanting to prevent more than 1 instance of this application from loading. But I need for it to also work in a terminal server. So I need to find a way of modifying this code to identify processes by individual user and not by the overall machine.
Any Ideas?

string proc = Process.GetCurrentProcess().ProcessName;
Process[] processes = Process.GetProcessesByName(proc);
Process[] processes = Process.GetProcessesByName(proc);
if (processes.Length > 1)
{
MessageBox.Show("The Assist Suite is alreay running");
Application.Exit();
}