您的位置:首页 > 产品设计 > UI/UE

通过GUID确保winform运行唯一实例

2016-02-26 13:26 351 查看

通过程序生成的GUIDwinform唯一实例

using System.Threading;bool createdNew;
Guid ownGUID = new Guid(((GuidAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),typeof(GuidAttribute))).Value);
Mutex instance = new Mutex(true, ownGUID.ToString("N"), out createdNew);
if (!createdNew) { MessageBox.Show("只能运行唯一实例"); return; }


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: