| | 4 | {{{ |
| | 5 | int GetProcessID(const string& strName, pid_t exclude = 0); |
| | 6 | |
| | 7 | int GetProcessID(const char* pszName, pid_t exclude = 0); |
| | 8 | }}} |
| | 9 | |
| | 10 | == Parameters == |
| | 11 | |
| | 12 | * strName - string name of process to check |
| | 13 | * pszName - character array name of process to check |
| | 14 | |
| | 15 | == Return Value == |
| | 16 | |
| | 17 | * Returns process ID if a process matches the name is found, 0 if not. |
| | 18 | |
| | 19 | == Remarks == |
| | 20 | |
| | 21 | |
| | 22 | == Examples == |
| | 23 | |
| | 24 | {{{ |
| | 25 | string strProc = "wtsvr"; |
| | 26 | if(GetProcessID(strProc) == 0) |
| | 27 | { |
| | 28 | DisplayText(0, 0, "Weight server is not running"); |
| | 29 | } |
| | 30 | }}} |
| | 31 | |
| | 32 | {{{ |
| | 33 | if(GetProcessID("wtsvr") == 0) |
| | 34 | { |
| | 35 | DisplayText(0, 0, "Weight server is not running"); |
| | 36 | } |
| | 37 | }}} |
| | 38 | |
| | 39 | {{{ |
| | 40 | if(GetProcessID("myapp", getpid()) == 0) |
| | 41 | { |
| | 42 | DisplayText(0, 0, "myapp already running"); |
| | 43 | exit(0); |
| | 44 | } |
| | 45 | }}} |
| | 46 | The example shows preventing running multiple instances of an application named "myapp". |
| | 47 | |
| | 48 | == See Also == |
| | 49 | |
| | 50 | * [http://tech.825spectrum.com/trac/wiki/Docs/Prog/Manual/ApplicationLibraries/lib825ev/Display/GetProcessIDExcludeSelf GetProcessIDExcludeSelf] |
| | 51 | * [http://tech.825spectrum.com/trac/wiki/Docs/Prog/Manual/ApplicationLibraries/lib825ev/Display/KillProcess KillProcess] |
| | 52 | |
| | 53 | |