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
|
|
|
|
|
2015-07-29 17:37:34 +02:00
|
|
|
:int CheckProcessExists(dword proc_name) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
:void RestartProcessByName(dword proc_name, byte multiple) {
|
|
|
|
KillProcessByName(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
|