跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

App.xaml.cs

42 行 · 1.0 KB历史下载
1using System;
2using System.Collections.Generic;
3using System.Configuration;
4using System.Data;
5using System.Linq;
6using System.Threading.Tasks;
7using System.Windows;
8
9namespace TaiBug
10{
11 /// <summary>
12 /// App.xaml 的交互逻辑
13 /// </summary>
14 public partial class App : Application
15 {
16 private System.Threading.Mutex mutex;
17
18 private void OnStartup(object sender, StartupEventArgs e)
19 {
20 // 阻止多开和用户主动启动
21 if (e.Args.Length == 0 || IsRuned())
22 {
23 Shutdown();
24 }
25 }
26 #region 获取当前程序是否已运行
27 /// <summary>
28 /// 获取当前程序是否已运行
29 /// </summary>
30 private bool IsRuned()
31 {
32 bool ret;
33 mutex = new System.Threading.Mutex(true, System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name, out ret);
34 if (!ret)
35 {
36 return true;
37 }
38 return false;
39 }
40 #endregion
41 }
42}