# CheckForDuplicateAppInstance

int CheckForDuplicateAppInstance (int activateOtherInstance, int *thereIsAnotherInstance);

## Purpose

Linux This function is not supported.

Determines if another copy of the same executable is running, but only if the other copy has already called this function. You can pass ACTIVATE_OTHER_INSTANCE in activateOtherInstance to bring the other copy to the foreground.

Use CheckForDuplicateAppInstance to prevent two instances of your application from running at the same time.

### Example

#include <cvirte.h>
int main (int argc, char *argv[])
{

int thereIsAnother;
if (InitCVIRTE (0, argv, 0) == 0)

return -1; /* out of memory */

if (CheckForDuplicateAppInstance (ACTIVATE_OTHER_INSTANCE, &thereIsAnother) < 0)

return -1; /* out of memory */

if (thereIsAnother)

return 0; /* prevent duplicate instance */

return 0;

}

## Parameters

Input
Name | Type | Description
activateOtherInstance | integer | Specifies whether to bring the other application instance, if one exists, to the foreground. Valid values are ACTIVATE_OTHER_INSTANCE or DO_NOT_ACTIVATE_OTHER_INSTANCE
Output
Name | Type | Description
thereIsAnotherInstance | integer | 1 if another instance of this executable exists; otherwise, 0. If CheckForDuplicateAppInstance returns an error code, this variable is always set to zero.

## Return Value

Name | Type | Description
status | integer | Indicates whether the function succeeded.
Code | Description
0 | Success.
-2 | Could not allocate system resources needed to check for a duplicate application instance.