热门文章
阿标在线 动力3.62HTML生成3.62网站文件说明
动力3.62整合动网7.0 SP2插
MDAC2.8 下载!
动力3.62版 防止垃圾留言
动力3.6全方位改动方法
让3.62不同频道实现不同风
把3.62首页登陆为横向代码
动易3.6首页随机FLASH修改
362首页和文章频道页图文幻
个性化修改3.6宝典
3.62轻易实现网摘功能
如何正确统计中文字数?
弹出JAVASCRIPT语法错误对
后台使“网站顶部LOGO地址
最新图片文章横向移动的修
html 生成艺术字
3.6 Sp2 Logo和Banner及广
日期值的计算
汉字转拼音
首页“图片更新”图片滚动
简体中文转换为繁体中文的
如何在css中定义链接的下划
防止同一个程序多次运行。 [VB.NET]
[ 录入:阿标 | 点击数: | 更新时间:2005-3-12 9:25:00]
防止同一个程序多次运行。
'*****************方法一:防止程序多次打开*****************
' 函数名: 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 False
End Function 'RunningInstance
'*****************方法二:防止程序多次打开*****************
Imports System.Diagnostics
If UBound(Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)) _
> 0 Then Eixt Sub
'Process.GetCurrentProcess.ProcessName 获取当前运行程序的名称。