View Full Version: Only one instance for an application

meos32 >>Help >>Only one instance for an application


RoniX- 04-03-2007
Only one instance for an application
Hi, I need a sample for an application that runs only one instance in the session... I mean, is there any way to avoid to start an application twice or more ? - Maybe I can find the process name and compare with my app name, but maybe that program name is the same and the program running is not the same, consider I have one program name "test" that do different things that my other program that is called "test" too... the purpose is that my program doesn't close another process that has the same name as my prog.. BTW: how can i get the name of my prog... (so i can change my program name from "test" to "test2" or whichever and get the filename and path) is there any way? I mean the executable filename that I'm starting. Does a program have an unique identification as a process like a handle name? Thx 4 ur help by advance ;)

hidnplayr- 04-04-2007

to retreive info about the proccess list, you migt want to take a look at the source code of the 'CPU' program (the task manager, when you press ctrl+alt+delete in kolibri) You might also be able to use IPC (internal process communication) to determine if the program with the same name, is your program.. BTW, why would you want to tun only one instance? :)

trolly- 04-04-2007

or look the code "cmd" application (it's old) he can be loaded only on instance. to do this, in the begin of the code, he scan all running process and get there name with a syscall, wen he fund a process that the name is the same (ie: 'cpu') the process end, otherwise he continue

RoniX- 04-04-2007

Thanks, I'll look them...

diamond- 04-05-2007

BTW: how can i get the name of my prog... (so i can change my program name from "test" to "test2" or whichever and get the filename and path) is there any way? I mean the executable filename that I'm starting. If the last field of MENUET01-header is not 0, it is interpreted as a pointer to 1024-byte area in which the kernel writes full path to application (like /hd0/1/kolibri/myapp/test2).

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.