mirror of
https://github.com/casksteven/Sweaty-Launcher.git
synced 2024-06-24 21:09:27 +00:00
41 lines
884 B
C#
41 lines
884 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Launcher.Common
|
|||
|
{
|
|||
|
internal class ProcessWatcher
|
|||
|
{
|
|||
|
public Process proc;
|
|||
|
EventHandler pro_Exited;
|
|||
|
public ProcessWatcher(EventHandler pro_Exited)
|
|||
|
{
|
|||
|
this.pro_Exited = pro_Exited;
|
|||
|
}
|
|||
|
|
|||
|
public void Watch()
|
|||
|
{
|
|||
|
Process[] ps = Process.GetProcesses();
|
|||
|
|
|||
|
foreach (Process p in ps)
|
|||
|
{
|
|||
|
if (p.ProcessName== "GenshinImpact"||p.ProcessName== "YuanShen")
|
|||
|
{
|
|||
|
proc = p;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (proc!=null)
|
|||
|
{
|
|||
|
proc.EnableRaisingEvents = true;
|
|||
|
proc.Exited += new EventHandler(pro_Exited);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|