互斥用户帐户是否具体? [英] Is mutex user account specific?

查看:82
本文介绍了互斥用户帐户是否具体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否特定于互斥锁用户帐户?



在我的应用程序中,我创建了一个互斥锁,以避免(为什么曾经)启动相同的(相同的=相同路径)exe两次。

如果我自己开始这个过程(例如通过浏览器双击)两次,一切正常。这意味着第二次启动无法创建互斥锁,因为互斥锁已经由第一个启动的进程创建,因此它会切换到已经启动的进程。



现在我通过Windows服务启动该过程的第一个实例,工作正常,没问题。但是当我自己再次启动相同的exe(浏览器双击)时,第二个启动过程可以创建相同的互斥锁......



我缺少什么?



提前谢谢。

Regadrs。

Is mutex user account specific?

In my application I create a mutex to avoid (why ever) to start the same (same == same path) exe twice.
Everything works fine if I start the process by myself (e.g. by explorer double click) twice. It means a second start can not create the mutex, because the mutex is already created by the first started process and so it does switch to the already started process.

Now I start the first instance of the process by a windows service, works fine, no problem. But when I start the same exe again by myself (explorer double click), the second started process can create the same mutex….

What I’m missing?

Thank you in advance.
Regadrs.

推荐答案

我是假设您在C ++中使用此标记而不是C#,但这里是CreateMutexEx的文档 http://msdn.microsoft.com/en-us/library/windows/desktop/ms682418(v = vs.85).aspx [ ^ ]。请注意,lpName参数可以具有Global或Local的前缀。这标识了互斥锁适用的会话。我猜你在这种情况下需要使用全局前缀。
I'm assuming you have this tagged right in C++ and not C#, but here is the documentation for CreateMutexEx http://msdn.microsoft.com/en-us/library/windows/desktop/ms682418(v=vs.85).aspx[^]. Notice the lpName parameter can have a prefix for Global or Local. This identifies what session the mutex applies to. I'm guessing that you need to use the global prefix in this case.


这篇关于互斥用户帐户是否具体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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