如果已经基于VB.NET中的loggined用户打开了应用程序,则限制应用程序启动? [英] Restrict application startup if already application is opened based on the loggined user in VB.NET?

查看:128
本文介绍了如果已经基于VB.NET中的loggined用户打开了应用程序,则限制应用程序启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想限制应用启动。

我已经通过使用此代码进行了限制。



Hi All,

I want to restrict the application start up.
Already I have restricted by Using this Code.

p = Process.GetProcessesByName("application.exe")
       If p.Count > 1 Then
          XtraMessageBox.Show("Application" & " is already running", "Meg", MessageBoxButtons.OK, MessageBoxIcon.Warning)
           End
       End If





工作正常。



但如果我在一个系统中有两个用户它已抛出应用程序正在运行。

因此我必须在验证中检查计算机的用户名。

应用程序应该在其他用户中打开。如果用户试图打开双倍时间,则必须限制它。



如何克服这个问题??







问候,

Palraj M



我尝试过:





It works fine.

But if I have two user in a system it throws already application is running.
so I have to check the user name of the computer too in the validation .
Application should open in the other user. if a user tries to open double time it has to be restricted.

how to overcome this issue??



Regards,
Palraj M

What I have tried:

p = Process.GetProcessesByName("application.exe")
       If p.Count > 1 Then
          XtraMessageBox.Show("Application" & " is already running", "Meg", MessageBoxButtons.OK, MessageBoxIcon.Warning)
           End
       End If

推荐答案

我很确定这是使用Mutex的时间:



被误解的互斥锁 [ ^ ]



互联网有点像锁,但它存在于所有.net进程中。您可以像上面链接中的示例一样为用户创建互斥锁,或者为终端服务计算机全局设置互斥锁,以便所有用户都可以看到它。



您想要第一个选项。如果Mutex不是全局的,则只有每个用户都可以看到自己的。确保程序在启动时检查互斥锁。如果它存在:已经运行,如果不存在:创建互斥并开始



希望有所帮助

Andy
I'm pretty sure this would be a time to use Mutex:

The Misunderstood Mutex[^]

A Mutex is "kinda" like a "lock", but it exists across all .net processes. You can create a Mutex for the user as in the examples in the link above, or set it globally for the terminal service machine so all instances for all users can see it.

You want the first option. If the Mutex is not global then only each user can see their own. Make sure the program checks for the mutex on startup. If it exists: "Already Running", if not: Create mutex and start

Hope that helps
Andy


这篇关于如果已经基于VB.NET中的loggined用户打开了应用程序,则限制应用程序启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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