[C# ] 防止程式重複執行
簡單的方法,Program.cs 加上判斷process
1
| using System.Diagnostics; |
1
2
3
4
5
6
7
8
9
| string ProcessName = Process.GetCurrentProcess().ProcessName;Process[] p = Process.GetProcessesByName(ProcessName);if (p.Length > 1){// Add CodeMessageBox.Show("重複執行!");Environment.Exit(1);} |
留言
張貼留言