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

ASP.NET
Internet Explorer 编程简述(二)在IE中编辑OLE嵌入文档
移动窗体
.NET 2.0获取数据库连接统计数据
VB.NET 拖动无边框的窗体
利用WH_CBT Hook将非模态对话框显示为模态对话框
Aspect#应用 - 权限验证
VB 从零开始编外挂(一)
【错误解决】Unable to find script library 'WebUIValidation.js'
VB 从零开始编外挂(四)
DTD指南(3)-DTD-Elements(元素)
知识库文章MDL9745154-File:Microsoft Visual Basic 运行时库
.net手机软件开发(六)OBEX应用:文件传输部分
在winform中使用WebBrowser控件时怎样去除IE的滚动条
WINZIP及WINRAR命令!!!!!
智能客户端相关Application Block结构功能分析(二)
如何在VB中操作EXCEL(一段代码,两个可以使用的过程)
在C#中用最简洁有效的代码执行存储过程并返回数据
.Net的Collection类的一些使用说明
ASP.NET实现数据图表c
用asp.net画饼图

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


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