当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 防止同一个程序多次运行。 [VB.NET]

ASP.NET
asp.net ajax功能强大的UpdatePanel控件
mscorwks.dll在.Net中的地位及代码保护应用
使用.NET实现你的IP切换器
在ADO.NET中用参数化查询缩短开发时间
Login控件:用户登录失败的消息提示
如何用C#来部署数据库
.net打包自动安装数据库
数据库开发个人总结(ADO.NET小结)
ASP.NET如何进行性能优化问题(2)
ASP.NET如何进行性能优化问题(1)
用.Net实现基于CSS的AJAX开发(6)
用.Net实现基于CSS的AJAX开发(5)
用.Net实现基于CSS的AJAX开发(4)
用.Net实现基于CSS的AJAX开发(3)
用.Net实现基于CSS的AJAX开发(2)
用.Net实现基于CSS的AJAX开发(1)
C#下用P2P技术实现点对点聊天
ASP.NET服务器端异步Web方法
在asp.net中如何从视频文件中抓取一桢并生成图像文件
.NET中多线程的同步资源访问

ASP.NET 中的 防止同一个程序多次运行。 [VB.NET]


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 23 ::
收藏到网摘: n/a

防止同一个程序多次运行。
'*****************方法一:防止程序多次打开*****************' 函数名: IsInstanceRunning ' 功 能: 判断工程是否已运行 ' 参 数: 无 ' 返回值: True 已运行 False 未运行 '******************************************************* Public Function IsInstanceRunning() As Boolean Dim current As Process = System.Diagnostics.Process.GetCurrentProcess() Dim processes As Process() = System.Diagnostics.Process.GetProcessesByName(current.ProcessName) 'Loop through the running processes in with the same name Dim p As Process For Each p In processes 'Ignore the current process If p.Id <> current.Id Then 'Make sure that the process is running from the exe file. If System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("/", "\") = current.MainModule.FileName Then 'Return the other process instance. Return True End If End If Next 'No other instance was found, return null. Return FalseEnd Function 'RunningInstance

'*****************方法二:防止程序多次打开*****************Imports System.Diagnostics If UBound(Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)) _ > 0 Then Eixt Sub'Process.GetCurrentProcess.ProcessName 获取当前运行程序的名称。