06-15-2014 05:58 PM - edited 06-15-2014 06:01 PM
Is there any problem with CheckForDuplicateAppInstance running under Windows XP?
I have just tried running oneinst sample project and found I was able torun it mulple times without problems
The system is WIndows XP PRO SP3 with full updates installed; the project is standard CVI2012 sample compiled and run multiple times. Ide is CVI2012 SP1 [ 12.0.1.127 ] the same as the run-time engine. CheckForDuplicateAppInstance returns no error and of course it returns no other instance running.
This is annoying since several of my customers are still using XP and I have this call in every application exactly to prevent more than one instance running...
06-18-2014 12:40 AM
Hi Roberto,
I have tried this on my WinXP Pro SP3 after compiling from CVI IDE 8.5.1 and 2013 SP1.
(Well, IDE version were different but probably the run-time was the same for both)
I can repeat that behaviour only if I do not explicitly terminate the program.
If you do nothing explicitly in your code, the function does not automatically turn off your application.
The functions outputs (second parameter pass by reference) whether there is already another instance is running or not.
You need to take action if that value is 1.
Hope this helps,
06-18-2014 01:57 AM
Hi eren,
thanks for looking into it but I don't understand your comment: I do not want to stop my application, I want that while the application is running I cannot launch it another time!
At present, immediately after starting the PC (so no program was launched and killed improperly before that moment) I can launch oneinst application several times. without quitting any of them, and this is undesirable.
06-18-2014 02:17 AM - edited 06-18-2014 02:18 AM
Maybe I did not understand you in the first place 😉 I will try to make myself clear.
What I am trying to say is, CheckForDuplicateAppInstance does not prevent or block other instances from executing.
It just informs you that there is another instance running. Whether you take action or not depends on you.
You can terminate that instance of your program when you realize (using the output of the function) that another instance is already running.
You can call the function immediately after InitCVIRTE and you will return from main if the second parameter returns true.
This will quit your second instance.
I attached my project.
If you compile and run it, you will see that extra instances can not display their panel.
If you comment line 50, then you can run multiple instances.
There is a very similar sample code in NI online help also.
06-18-2014 03:19 AM - edited 06-18-2014 03:20 AM
Ok, all is clear now.
I am experimenting with a sample project from NI (samples\utility\oneinst.prj) that is intended exactly to demonstrate CheckForDuplicateAppInstance features; its code is very similar to yours: it should prevent other instances to run but it does not on my machine.
It could be that my machine is faulty, but as far as I know this is the only strange thing I'm seeing; or that particular run-time could have problems under Xp; it could even be due to something else I cannot figure at the moment. Till now I record that on your machine all works well. In the next days I will visit a customer of mine and I will make some checks there.