Re: [.NET] 如何防止重複執行?

看板Visual_Basic作者 (麥田)時間17年前 (2007/04/07 00:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《mywheat (麥田)》之銘言: : 請問一下,該怎麼禁止使用者重覆啟動程式? : 因為週邊的應用,如果重複執行這隻程式,會造成錯誤。 自問自答.. 放在 form_load 中 Dim AppName As String = Process.GetCurrentProcess.ProcessName Dim count As Integer = 0 For Each proc As Process In Process.GetProcesses() If AppName = proc.ProcessName.ToString Then count += 1 Next If count > 1 Then Me.Close() -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.167.50.91 ※ 編輯: mywheat 來自: 218.167.50.91 (04/07 00:19)
文章代碼(AID): #165dB6e_ (Visual_Basic)
文章代碼(AID): #165dB6e_ (Visual_Basic)