防止应用程序多次启动 [英] Preventing an app from being launched more than once

查看:94
本文介绍了防止应用程序多次启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用以下示例:
http://www.yoda.arachsys.com/csharp/...ation.instance


完全适用于Vista,但不适用于XP ...


不会丢失任何错误,但应用程序的多次启动不是

被阻止。


还有其他解决方案吗?


感激不尽的任何帮助。


-
http://www.markrae.net

Hi,

I''m using the following example for this:
http://www.yoda.arachsys.com/csharp/...ation.instance

which works perfectly on Vista, but not on XP...

Doesn''t throw any errors, but multiple launches of the app are not
prevented.

Is there another solution?

Any assistance gratefully received.

--
http://www.markrae.net

推荐答案

Mark,


此前一个帖子指出:

http://groups.google.com/group/micro...8f00c1a?hl=en&


基本上,你要去使用Microsoft.VisualBasic命名空间中的WindowsFormsApplicationBase类。

-

- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com


Mark Rae < ma ** @ markNOSPAMrae.net写信息

新闻:%2 ****************** @ TK2MSFTNGP04.phx.gbl ...
Mark,

This previous thread indicates how:

http://groups.google.com/group/micro...8f00c1a?hl=en&

Basically, you are going to use the WindowsFormsApplicationBase class in
the Microsoft.VisualBasic namespace.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...




我正在使用以下示例:
http://www.yoda.arachsys.com/csharp/ .. .ation.instance


完全适用于Vista,但不适用于XP ...


不扔任何错误,但应用程序的多次启动都不会被阻止。


还有其他解决方案吗?


感激不尽的任何帮助。


-
http ://www.markrae.net



" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com写在

消息新闻:%2 **************** @ TK2MSFTNGP05.phx.gbl .. 。
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2****************@TK2MSFTNGP05.phx.gbl...

前一个帖子表明:

http://groups.google.com/group/micro...8f00c1a?hl=en&


基本上,你要去在Microsoft.VisualBasic命名空间中使用WindowsFormsApplicationBase类


This previous thread indicates how:

http://groups.google.com/group/micro...8f00c1a?hl=en&

Basically, you are going to use the WindowsFormsApplicationBase class
in the Microsoft.VisualBasic namespace.



哎哟!在C#应用程序中使用Microsoft.VisualBasic命名空间......?


嗯 - 好吧,我想我将不得不停止对此如此肛门!


好​​奇Jon的代码在Vista上完美运行,但是...

-
http://www.markrae.net

Ouch! Use the Microsoft.VisualBasic namespace in a C# app...?

Hmm - OK, I guess I''ll have to stop being so anal about that!

Curious that Jon''s code works perfectly on Vista, though...
--
http://www.markrae.net


Mark Rae写道:
Mark Rae wrote:




我正在使用以下示例:
http://www.yoda.arachsys.com/csharp / ... ation.instance


完全适用于Vista,但不适用于XP ...


不扔任何东西错误,但是应用程序的多次启动都没有被阻止。


还有其他解决方案吗?


任意非常感谢你的帮助。
Hi,

I''m using the following example for this:
http://www.yoda.arachsys.com/csharp/...ation.instance

which works perfectly on Vista, but not on XP...

Doesn''t throw any errors, but multiple launches of the app are not
prevented.

Is there another solution?

Any assistance gratefully received.






您是否看到有关它是本地互斥的评论?您是在单个用户会话中测试多次启动应用程序,还是在用户会话中测试
(例如终端服务或快速用户切换)?


如果是后者,你需要使互斥量全局化。如果是前者,那么

奇怪的是它不起作用......也许这是一个权限问题。


-

Tom Spink

爱丁堡大学

Hi,

Did you see the comment about it being a local mutex? Are you testing
multiple launches of the application within a single user session, or
across user sessions (e.g. terminal services or fast user switching)?

If the latter, you''ll need to make the mutex global. If the former, then
it''s strange that it doesn''t work... Perhaps it''s a permissions issue.

--
Tom Spink
University of Edinburgh


这篇关于防止应用程序多次启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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