Simple C# code which checks for running app

shod4n

Новичок
Регистрация
26.08.2017
Сообщения
2
Благодарностей
0
Баллы
1
Hello everyone. I have a simple C# code which checks for running processes, e.g. notepad.exe. I would like to include it in my project and parse the result to a variable. The code outputs a boolean. Here it is:

Код:
public static class ProcessHelpers {
public static bool IsRunning (string name) => Process.GetProcessesByName(name).Length > 0;
}

I've already added it to OwnCodeUsings, and I also included:

Код:
using System.Diagnostics;

Here's a screenshot:



Now I'm kinda stuck with next step. I know that I need to call it from the Own C# as you can see here:



But unfortunately I have no idea what code to include so the result is passed to the variable entered below. I'm using this code to check whether cmd.exe process is running or not.

Thanks a lot for any help. Cheers!
 

enrc66

Client
Регистрация
12.10.2013
Сообщения
89
Благодарностей
8
Баллы
8
try this:
public static bool IsRunning (string name)
{
return System.Diagnostics.Process.GetProcessesByName(name).Length > 0;
}

then
c# code:
return ZennoLab.OwnCode.CommonCode.IsRunning("cmd");
 
  • Спасибо
Реакции: LightWood и shod4n

shod4n

Новичок
Регистрация
26.08.2017
Сообщения
2
Благодарностей
0
Баллы
1

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)