维护单实例应用程序

维护单实例应用程序

问题描述:

我一直对这个应用我的,得到了​​这个问题。通过与不同的参数命令行
上运行程序打开不同的.exe程序。

I have been working on this application of mine and got this problem. Running program through command line with different arguments opens different .exe process.

我的问题是如何从打开同一个文件几次阻止了,是不是可以发送新的命令行参数的应用已经打开的实例。

My question is how can i prevent from opening same file few times, and is it possible to send new command line arguments to already open instance of application.

感谢。

下面是一个快速的方法来做到这一点。只需要使用互斥锁。

Here is a quick way to do it. Just use a mutex lock.

http://en.csharp-online.net/CSharp_FAQ:_How_ensure_that_only_one_instance_of_an_application_will_run

MSDN互斥锁