04-19-2010 02:54 AM
HiAll
Some info.
I wrote a program which runs from a shortcut with attributes, each shortcut contains different attributes.
How can i run only one instance of this program but when i open a the program with a different shortcut(while the inital program is open) the one program instance must user this shortcut attributes?
Thanks
Shako
04-19-2010 07:43 AM - edited 04-19-2010 07:44 AM
Hi Shako,
CVI has CheckForDuplicateAppInstance () function that prmits you to know if another instance of the app is already running. You can use it as a way to prevent multiple instances of your app to be running. To be detected, other instances of the application must already have called the function, as explained in the online help.
With reference to launch parameters, they are normally recevied in argv [] parameter of the main (), in which the forst parameter is always the program name, while other parameters are listedin the following elements of the array. argc parameter stores the number of command line parameters the progra was caled with.
To debug this option you can use Run >> Command line... menu option, which allows you to input every additional parameter you want so that it's easy for you to debug program activity in every case.
04-19-2010 08:01 AM
I understand that CheckForDuplicateAppInstanc() is used to let you know if another instance wants to start so that you can stop it.
I am currently using argv and argc and it is working brilliantly.
But my problem is how do i get the value (argv,argc) from the second instance to be used in my currently opened instance.
Or how do i close the current instance to make the second instance the only one open ?
An Example is any media player, when you double click on an mp3 it opens the media player, while the media player is open and you double click on another mp3 the media
player changers what its playing to your last select mp3 with out opening another instance of the media player.
How do i do that ?