The function CheckForDuplicateAppInstance can be used in this scenario. I have included a code snipet on how to use this function. If you have any questions, let me know. Also, check out
this dev zone example to see another method.
#include <userint.h>
#include <utility.h>
#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)
{
// Terminate the Program
MessagePopup("Warning","Another Instance of the Executable is running!");
return 0; /* prevent duplicate instance */
}
else
{
// Put your code here
MessagePopup("Test", "Program Running...");
}
return 0;
}