国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 扎鲁特旗| 兴城市| 扶风县| 泽库县| 平塘县| 台湾省| 汉源县| 庆阳市| 微博| 忻州市| 武陟县| 长武县| 三门峡市| 雷波县| 乳山市| 邻水| 安远县| 高碑店市| 盈江县| 宁明县| 图们市| 成安县| 钟祥市| 陇南市| 克东县| 汉川市| 清流县| 八宿县| 小金县| 喜德县| 松溪县| 兰坪| 云龙县| 德安县| 徐汇区| 临夏市| 阿拉善盟| 清镇市| 云梦县| 商水县| 思南县|