国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

防止同一個(gè)程序多次運(yùn)行。 [VB.NET]

2024-07-10 13:00:55
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

商業(yè)源碼熱門(mén)下載www.html.org.cn

防止同一個(gè)程序多次運(yùn)行。
'*****************方法一:防止程序多次打開(kāi)*****************
' 函數(shù)名: isinstancerunning
' 功 能: 判斷工程是否已運(yùn)行
' 參 數(shù): 無(wú)
' 返回值: true 已運(yùn)行 false 未運(yùn)行
'*******************************************************
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

'*****************方法二:防止程序多次打開(kāi)*****************
imports system.diagnostics
if ubound(process.getprocessesbyname(process.getcurrentprocess.processname)) _
> 0 then eixt sub
'process.getcurrentprocess.processname 獲取當(dāng)前運(yùn)行程序的名稱(chēng)。



發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 景东| 固原市| 乌拉特前旗| 进贤县| 民勤县| 永年县| 洛南县| 武乡县| 淮阳县| 铜山县| 通城县| 盐津县| 乌鲁木齐市| 黑龙江省| 灵丘县| 水富县| 隆回县| 定安县| 博客| 子洲县| 龙州县| 奉化市| 镇安县| 五寨县| 阿荣旗| 西华县| 临潭县| 淮安市| 宜黄县| 高要市| 丹寨县| 边坝县| 峨边| 靖远县| 怀安县| 宽城| 云梦县| 新疆| 左云县| 双牌县| 清水河县|