程序运行的2个实例 [英] 2 instances of the program running

查看:89
本文介绍了程序运行的2个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个VB.net Windows窗体应用程序。如果我运行程序

然后我再次错误地点击我的桌面图标,我会得到第二个运行该程序的
实例。无论如何都要检查/阻止

第二个实例启动,然后带我到已经运行的

应用程序。 (我已经看过过去的应用程序了...双击

点击桌面图标只会调出已经运行最少的

应用程序。)


非常感谢任何帮助!

Chris
ct ** ****@pierceassociates.com

I have created a VB.net windows forms application. If I have the program
running and then I mistakenly click on my desktop icon again, I get a second
instance of the program running. Is there anyway to check / prevent a
second instance to startup and just take me to the already running
application. (I have seen applications in the past do this... double
clicking on the desktop icon just brings up the already running minimized
application.)

Any help would be greatly appreciated!
Chris
ct******@pierceassociates.com

推荐答案

Chris Thunell< ct ****** @ pierceassociates.com>写道:
Chris Thunell <ct******@pierceassociates.com> wrote:
我创建了一个VB.net Windows窗体应用程序。如果我运行程序
然后我再次错误地点击我的桌面图标,我会得到第二个正在运行的程序实例。反正有没有检查/阻止第二个实例启动,只是带我到已经运行的
应用程序。 (我已经看到过去的应用程序这样做...双击
点击桌面图标只会调出已经运行的最小化的应用程序。)
I have created a VB.net windows forms application. If I have the program
running and then I mistakenly click on my desktop icon again, I get a second
instance of the program running. Is there anyway to check / prevent a
second instance to startup and just take me to the already running
application. (I have seen applications in the past do this... double
clicking on the desktop icon just brings up the already running minimized
application.)




请参阅 http:// www。 pobox.com/~skeet/csharp/f...ation.instance

-

Jon Skeet - < sk ** *@pobox.com>
http://www.pobox.com/~双向飞碟

如果回复小组,请不要给我发邮件



See http://www.pobox.com/~skeet/csharp/f...ation.instance

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


克里斯

这可能有用
http://msdn.microsoft.com/library/de...eaworapps1.asp

检查单个实例部分


HTH

Alex


" Chris Thunell" ; <克拉****** @ pierceassociates.com>在消息中写道

news:uf ************** @ TK2MSFTNGP10.phx.gbl ...
Hi, Chris

this might be useful
http://msdn.microsoft.com/library/de...eaworapps1.asp
Check single instance section

HTH
Alex

"Chris Thunell" <ct******@pierceassociates.com> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...
我创建了一个VB .net windows表单应用程序。如果我运行程序
然后我再次错误地点击我的桌面图标,我会得到
的第二个程序运行实例。反正有没有检查/阻止第二个实例启动,只是带我到已经运行的
应用程序。 (我已经看到过去的应用程序这样做...双击
点击桌面图标只会调出已经运行的最小化的应用程序。)

任何帮助都会很大感谢!
Chris
ct******@pierceassociates.com
I have created a VB.net windows forms application. If I have the program
running and then I mistakenly click on my desktop icon again, I get a second instance of the program running. Is there anyway to check / prevent a
second instance to startup and just take me to the already running
application. (I have seen applications in the past do this... double
clicking on the desktop icon just brings up the already running minimized
application.)

Any help would be greatly appreciated!
Chris
ct******@pierceassociates.com



如果您在VS / VB中搜索PrevInstance,您将获得以下代码

block


函数PrevInstance()As Boolean

如果

Ubound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))
If you do a search for PrevInstance in VS/VB you will get the following code
block

Function PrevInstance() As Boolean
If
Ubound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))
0然后
返回True

否则

返回错误

结束如果

结束功能


只需从Sub Main调用它()


Sub Main

如果不是PrevInstance那么

Dim MainForm作为新的Form1''(或其他)

Application.Run(MainForm)

结束如果

End Sub

" Chris Thunell" <克拉****** @ pierceassociates.com>在消息中写道

news:uf ************** @ TK2MSFTNGP10.phx.gbl ...我创建了一个VB.net Windows窗体应用程序。如果我运行程序
然后我再次错误地点击我的桌面图标,我会得到一个运行程序的第二个实例。反正有没有检查/阻止第二个实例启动,只是带我到已经运行的
应用程序。 (我已经看到过去的应用程序这样做...双击
点击桌面图标只会调出已经运行的最小化的应用程序。)

任何帮助都会很大感谢!
Chris
ct******@pierceassociates.com
0 Then Return True
Else
Return False
End If
End Function

Just call it from Sub Main()

Sub Main
If Not PrevInstance Then
Dim MainForm as new Form1 ''(or whatever)
Application.Run(MainForm)
End if
End Sub
"Chris Thunell" <ct******@pierceassociates.com> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...I have created a VB.net windows forms application. If I have the program
running and then I mistakenly click on my desktop icon again, I get a
second
instance of the program running. Is there anyway to check / prevent a
second instance to startup and just take me to the already running
application. (I have seen applications in the past do this... double
clicking on the desktop icon just brings up the already running minimized
application.)

Any help would be greatly appreciated!
Chris
ct******@pierceassociates.com



这篇关于程序运行的2个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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