使用进程名禁止程序运行多次

string moduleName = Process.GetCurrentProcess().MainModule.ModuleName;
string prcessName = System.IO.Path.GetFileNameWithoutExtension(moduleName);
Process[] processes = Process.GetProcessesByName(prcessName);
if (processes.Length>1)
{
    MessageBox.Show("程序已经运行!");
    Process.GetCurrentProcess().Kill();
}
posted @ 2015-05-30 23:59  邪不压正!  阅读(179)  评论(0编辑  收藏  举报