TMusic.Util/ProcessUtil.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace TMusic.Util
{
    public static class ProcessUtil
    {
        public static void Start(string path, string args = null)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            try
            {
                string name = Path.GetFileNameWithoutExtension(path);
                var p = GetProcess(name);
                if (p == null)
                {
                    _ = Process.Start(path, args);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

        public static void Kill(string name)
        {
            var p = GetProcess(name);
            if (p != null)
            {
                p.Kill();
            }
        }

        public static Process GetProcess(string name)
        {
            var ps = Process.GetProcessesByName(name);
            if (ps != null && ps.Length > 0)
            {
                return ps.FirstOrDefault();
            }
            return null;
        }

        public static Process GetCurrentProcess()
        {
            string name = GetCurrentProcessName();
            return GetProcess(name);
        }

        public static bool IsStarted(string name)
        {
            return GetProcess(name) != null;
        }

后面还有 13 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。