2015-07-22 20:32:54 +02:00
|
|
|
#ifndef INCLUDE_RESTART_PROCESS_H
|
|
|
|
#define INCLUDE_RESTART_PROCESS_H
|
|
|
|
|
|
|
|
#ifndef INCLUDE_KOLIBRI_H
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#endif
|
|
|
|
|
2015-03-25 12:46:22 +01:00
|
|
|
enum {
|
|
|
|
MULTIPLE,
|
|
|
|
SINGLE
|
|
|
|
};
|
|
|
|
|
2016-11-14 01:42:32 +01:00
|
|
|
#define MAX_PROCESS_COUNT 256
|
|
|
|
|
2018-10-04 19:53:33 +02:00
|
|
|
:bool CheckProcessExists(dword proc_name) {
|
2015-07-29 17:37:34 +02:00
|
|
|
int i;
|
|
|
|
proc_info Process;
|
2016-11-14 01:42:32 +01:00
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
2015-07-29 17:37:34 +02:00
|
|
|
{
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
if (strcmpi(#Process.name, proc_name)==0) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
:void KillProcessByName(dword proc_name, byte multiple) {
|
2015-03-25 12:46:22 +01:00
|
|
|
int i;
|
|
|
|
proc_info Process;
|
2016-11-14 01:42:32 +01:00
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
2015-03-25 12:46:22 +01:00
|
|
|
{
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
if (strcmpi(#Process.name, proc_name)==0)
|
|
|
|
{
|
|
|
|
KillProcess(Process.ID);
|
|
|
|
if (multiple==SINGLE) break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-29 17:37:34 +02:00
|
|
|
}
|
|
|
|
|
2020-05-12 01:02:41 +02:00
|
|
|
:int GetProcessesCount(dword proc_name) {
|
|
|
|
int i, count=0;
|
|
|
|
proc_info Process;
|
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
|
|
|
{
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
if (strcmpi(#Process.name, proc_name)==0) count++;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2015-07-29 17:37:34 +02:00
|
|
|
:void RestartProcessByName(dword proc_name, byte multiple) {
|
2019-05-14 15:07:29 +02:00
|
|
|
KillProcessByName(proc_name + strrchr(proc_name, '/'), multiple);
|
2015-03-25 12:46:22 +01:00
|
|
|
RunProgram(proc_name, "");
|
2015-07-22 20:32:54 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 17:37:34 +02:00
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
#endif
|