Posted By: wdakfenixx
Open and openning programs? - 05/10/12 21:35
Hi, I just want to ask two things, Is it posible to detect if the same program is already running on the machine and if is possible to execute another program from the one you write on lite-C
Posted By: Espér
Re: Open and openning programs? - 05/10/12 21:46
an idea would be to write a variable into the registry, and set it to 1, 2..3..etc just the count of how many times a program is opened at the same time, and lower the value if one of the programs closes.
Now you can readout the registry, and ask if this value is 1 or higher.
executing other porgrams, calling a webpage or documents.. are done by using exec
Posted By: Uhrwerk
Re: Open and openning programs? - 05/10/12 22:02
You should have a look at
http://www.conitec.net/beta/sys_active.htmand
http://www.conitec.net/beta/ain-exec.htmEspers suggestion concerning the registry is dangerous in terms of concurrency. You cannot atomically read and write a registry value.
Posted By: Gordon
Re: Open and openning programs? - 05/10/12 23:22
If you do all the registry access in main before you load a level or do a wait then it should be ok. However you want fully locked access then just create a mutex and do a read modify write operation there then test the value after closing the mutex. The only way that an unprotected read modify write operation would fail is if you got a windows task switch in the middle AND your doing the same operation in another program at the same time. If it is limited to program start and program end then the chance of failure is minimal as it is very difficult to start or end programs at the same time.
Posted By: Superku
Re: Open and openning programs? - 05/10/12 23:24
And if you are talking about a server/ client application, try to use session_open and session_connect instead of the command line options.
Posted By: sivan
Re: Open and openning programs? - 05/11/12 06:35
or a stupid solution to create a file on startup and delete it on close. so you can check it with file_exists. the problem if it is not deleted because of an unhandled crash.
Posted By: wdakfenixx
Re: Open and openning programs? - 05/13/12 20:32
thank you, it has been very useful