private void Window_Loaded(object sender, RoutedEventArgs e)
{
Process[] pro = Process.GetProcesses();
int n = pro.Where(p => p.ProcessName.Equals("InfusionBagSmartLaber")).Count();
if (n > 1)
{
MessageBox.Show("应用程序已经启动了");
//Application.Current.Shutdown();
Environment.Exit(0);
return;
}
}
WPF程序不允许重复执行
最新推荐文章于 2024-11-20 14:24:55 发布
此篇博客介绍了如何使用C#代码检测名为'InfusionBagSmartLaber'的应用是否已启动,若发现多个实例,提示用户并可能强制退出程序。

1492

被折叠的 条评论
为什么被折叠?



