C#停止程序打开它自己多一次 [英] C# stop program from opening its self more then once

查看:67
本文介绍了C#停止程序打开它自己多一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如此苛刻地你将你的程序作为.exe发布,你可以打开它一次,我想知道如何制作它所以你只能让其中一个程序打开,这样用户就不能打开程序了一次就像Skype

解决方案

当你运行一个应用程序时,它的实例是在进程中创建的

所以如果你需要看到它的实例已经运行

  string  procName = Process.GetCurrentProcess()。ProcessName; 
if (Process.GetProcessesByName(procName).Length == 1
{
...代码在这里......
}



或者您可以直接从项目属性中设置它预防.Net Applicationl的多个实例 [ ^ ]



你可以用任何方式完成


请参考链接:

Link1

Link2
链接3

so bascicly you release your program as an .exe you can open it more then once, I was wondering how to make it so you can only have one of the program open, so that the user cannot open the program more then once just like "Skype"

解决方案

When you run an application its instance is created in process
so if you need to see that its instance already running

string procName = Process.GetCurrentProcess().ProcessName;
  if (Process.GetProcessesByName(procName).Length == 1)
  {
      ...code here...
  }


Or you can directly set it from Project properties Preventing multiple instances of .Net Applicationl[^]

You can do it in any of the way


Please refer links:
Link1
Link2
Link3


这篇关于C#停止程序打开它自己多一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆