wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Process/GetProcessID

GetProcessID

Get the process ID of the specified name

int GetProcessID(const string& strName, pid_t exclude = 0);

int GetProcessID(const char* pszName, pid_t exclude = 0);

Parameters

  • strName - string name of process to check
  • pszName - character array name of process to check

Return Value

  • Returns process ID if a process matches the name is found, 0 if not.

Remarks

Examples

string strProc = "wtsvr";
if(GetProcessID(strProc) == 0)
{
  DisplayText(0, 0, "Weight server is not running");
}
if(GetProcessID("wtsvr") == 0)
{
  DisplayText(0, 0, "Weight server is not running");
}
if(GetProcessID("myapp", getpid()) == 0)
{
  DisplayText(0, 0, "myapp already running");
  exit(0);
}

The example shows preventing running multiple instances of an application named "myapp".

See Also

Last modified 6 years ago Last modified on 04/12/18 13:06:12
Note: See TracWiki for help on using the wiki.