如何使用 vb.net 检查应用程序是否已在运行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17724366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to check the application is already running using vb.net..?
提问by Srivani
how to check the application is already running using vb.net,if the application is running switch to that application how to do that using vb.net..?
如何使用 vb.net 检查应用程序是否已在运行,如果应用程序正在运行切换到该应用程序如何使用 vb.net 执行此操作?
Please help me
请帮我
Thanks in advance..
提前致谢..
Public Function IsProcessRunning(ByVal name As String) As Boolean
For Each clsProcess As Process In Process.GetProcesses()
If clsProcess.ProcessName.StartsWith(name) Then
Return True
End If
Next
Return False
End Function
Private Sub adxcmbSwitchtoDLtool_Click(ByVal sender As System.Object) Handles adxcmbSwitchtoDLtool.Click
Dim path As String = "D:\SRIVANI\DLEWISSCM\DictaSolicitor\bin\Debug\DictaSolicitor.EXE"
If IsProcessRunning(path) = True Then
Else
Process.Start(path)
End If
end sub
i wrote code like that if i click on the button my application is open and again i click on the button again my application is running..how many times i click the button those many times the application is running how to check the opened application and switch to the application............
我写了这样的代码,如果我点击按钮我的应用程序是打开的,然后我再次点击按钮我的应用程序正在运行..我点击按钮多少次应用程序正在运行如何检查打开的应用程序和切换到应用程序…………
回答by sloth
Just enable the "Make single-instance application" checkbox in your application properties.
只需在您的应用程序属性中启用“制作单实例应用程序”复选框。

