2015-07-22 21:32:54 +03:00
|
|
|
#ifndef INCLUDE_RESTART_PROCESS_H
|
|
|
|
#define INCLUDE_RESTART_PROCESS_H
|
|
|
|
|
|
|
|
#ifndef INCLUDE_KOLIBRI_H
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#endif
|
|
|
|
|
2015-03-25 14:46:22 +03:00
|
|
|
enum {
|
|
|
|
MULTIPLE,
|
|
|
|
SINGLE
|
|
|
|
};
|
|
|
|
|
2016-11-14 03:42:32 +03:00
|
|
|
#define MAX_PROCESS_COUNT 256
|
|
|
|
|
2015-07-29 18:37:34 +03:00
|
|
|
:int CheckProcessExists(dword proc_name) {
|
|
|
|
int i;
|
|
|
|
proc_info Process;
|
2016-11-14 03:42:32 +03:00
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
2015-07-29 18:37:34 +03: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 14:46:22 +03:00
|
|
|
int i;
|
|
|
|
proc_info Process;
|
2016-11-14 03:42:32 +03:00
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++;)
|
2015-03-25 14:46:22 +03:00
|
|
|
{
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
if (strcmpi(#Process.name, proc_name)==0)
|
|
|
|
{
|
|
|
|
KillProcess(Process.ID);
|
|
|
|
if (multiple==SINGLE) break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-29 18:37:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
:void RestartProcessByName(dword proc_name, byte multiple) {
|
|
|
|
KillProcessByName(proc_name, multiple);
|
2015-03-25 14:46:22 +03:00
|
|
|
RunProgram(proc_name, "");
|
2015-07-22 21:32:54 +03:00
|
|
|
}
|
|
|
|
|
2015-07-29 18:37:34 +03:00
|
|
|
|
2015-07-22 21:32:54 +03:00
|
|
|
#endif
|