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

ASP.NET
ACCESS数据库访问组件(三)
ACCESS数据库访问组件(四)
在ASP.NET访问Excel文件
使用正则表达式解析的初步体会(固定格式网页解析)
一段找出URL的代码(C#)
C#中的转意字符序列
创建表,创建行,创建列(VB.NET)
刀兄写的IIS管理类(C#)
索引服务调用代码(C#)
VB.NET里奇怪的数组赋值现象
C#运算符的优先顺序
[初学VB.NET]如何防止重复打开MDI子窗体
第二版出错的地方,大家看看第三版我的翻译对么?
VB的API编程精粹
表格架构基本框架DEMO码
用C#实现在客户区拖动窗体(转自MSDN)
在ASP.NET中利用GDI+ 设计Chart控件
关于JAXP,DOM,SAX,JDOM,DOM4J的一些想法
Nucleus.MockAOP.Net:OpenSource .Net AOP FrameWork
VB中打印ACCESS报表

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


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