PSingleInstance Class Reference

Detailed Description

The PSingleInstance class provides a simple mechanism to check if several instances of the same application are running simultaneously.

// in your main, add the following code:
PSingleInstance si("myApplication");
if (si.IsAlreadyRunning())
return PResult::Error("Can't run multiple instances of this application");

Definition at line 35 of file PSingleInstance.h.

#include <PSingleInstance.h>

Constructor & Destructor Documentation

◆ PSingleInstance()

PSingleInstance::PSingleInstance ( const char *  uniqueName)
explicit

Constructs an instance of PSingleInstance from the name of your application.

The name will be used to check of another instance of the same application is already running.

Idiom is the following:

// in your main, add the following code:
PSingleInstance si("myApplication");
if (si.IsAlreadyRunning())
return PResult::Error("Can't run multiple instances of this application");
See also
IsAlreadyRunning()

◆ ~PSingleInstance()

virtual PSingleInstance::~PSingleInstance ( )
virtual

Destroys this object.

Member Function Documentation

◆ IsAlreadyRunning()

bool PSingleInstance::IsAlreadyRunning ( ) const

Returns true if another application with the same name is already running, false otherwise.