CheckForDuplicateAppInstance
- Updated2023-02-21
- 1 minute(s) read
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 Code
#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 | int | Specify a nonzero value or ACTIVATE_OTHER_INSTANCE or select Yes in the function panel to bring the other application instance, if one exists, to the foreground. Specify 0 or DO_NOT_ACTIVATE_OTHER_INSTANCE or select No in the function panel if you do not want to bring the other application instance to the foreground. |
Output | ||
Name | Type | Description |
thereIsAnotherInstance | int | 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 | int | Indicates whether the function succeeded.
|
Additional Information
Library: Utility Library
Include file: utility.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to utility\oneinst.cws for an example of using the CheckForDuplicateAppInstance function.