OP 17 February, 2022 - 07:41 PM
I have a small program idea that I've been trying to execute for months but I've hit a dead end with this small thing.
I'm looking for a way to detect a certain process running through task manager and then get its path, and I've found a way to do so.
The problem is I need to make my program listen for the process so it detects it as soon as it runs, but I haven't found any way to loop it without crashing or failing, I know it's a small matter and that's why it's driving me nuts.
I'm looking for a way to detect a certain process running through task manager and then get its path, and I've found a way to do so.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Diagnostics;
using System.Management;
string fullPath = process.MainModule.FileName;
Process currentProsseses = Process.GetCurrentProcess();
Process[] list = Process.GetProcessesByName("ProcessName");
foreach (var process in list)
{
string fullPath = process.MainModule.FileName;
// display detected process name
MessageBox.Show(fullPath);
}
The problem is I need to make my program listen for the process so it detects it as soon as it runs, but I haven't found any way to loop it without crashing or failing, I know it's a small matter and that's why it's driving me nuts.