UniqueTool.cs 582 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace Y.Utils.AppUtils
  8. {
  9. public class UniqueTool
  10. {
  11. /// <summary>
  12. /// 判断应用在当前系统实例下是否唯一
  13. /// </summary>
  14. /// <param name="appName"></param>
  15. /// <returns></returns>
  16. public static bool IsUnique(string appName)
  17. {
  18. bool unique;
  19. Mutex run = new Mutex(true, appName, out unique);
  20. return unique;
  21. }
  22. }
  23. }