1. 程式人生 > >WPF 控制程序只能啟動一次

WPF 控制程序只能啟動一次

details tail right star 原創 .sh hand bool ron

原文:WPF 控制程序只能啟動一次

版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/jsyhello/article/details/7411898

??? public partial class App : Application
??? {
??????? System.Threading.Mutex mutex;

??????? public App()
??????? {
??????????? this.Startup += new StartupEventHandler(App_Startup);
??????? }

??????? void App_Startup(object sender, StartupEventArgs e)
??????? {
??????????? bool ret;
??????????? mutex = new System.Threading.Mutex(true, "WpfMuerterrrterterttex", out ret);
??????????? if (!ret)
??????????? {
??????????????? MessageBox.Show("Program has started, you can‘t start again!");
??????????????? Environment.Exit(0);
??????????? }
??????? }
??? }

感謝:http://www.cnblogs.com/xiaokang088/archive/2011/03/29/1998710.html

?

歡迎訪問:http://121.18.78.216 適易查詢分析、工作流、內容管理及項目管理演示平臺

WPF 控制程序只能啟動一次