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

ASP.NET
如何在命令行下编译一个asp.net项目
ADO 与ADO.NET
当VS.NET2003遇上VS.NET2005,WebService部署何去何从
昨日关注:逐步解说: 将Web Form网页国际化
在.NET下编写中文代码程序
防止同一个程序多次运行。 [VB.NET]
Visual C#设计多功能关机程序
什么是Web Service?
实现ListView控件的行间隔颜色的优化代码
失去信心?还是再度迷惘(二):Mono only is Mono,not .NET never
在Winform中发HTTP请求(调用WebService服务)
.NET中加密和解密的实现方法 3
notNET中加密和解密的实现方法
.NET中加密和解密的实现方法2
mshtml:javascript为HTML文件中的Select添加option
VS.NET解决方案的兼容问题
关于创建快捷方式的小结
使用 GDI+ 进行双缓冲绘图
如何用DataGrid实现根据日期判断是否显示New标志
昨日关注:C-omega vs ADO.net

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 34 ::
收藏到网摘: 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 获取当前运行程序的名称。