Simple C# code which checks for running app

  • Автор темы Автор темы shod4n
  • Дата начала Дата начала

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:

D6x3MIc.png


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:

d8hWu80.png


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!
 
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

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