Metaborn Posted June 26, 2007 Share Posted June 26, 2007 I'm trying to create a program that will set in the background and monitor stuff. I don't want more then one copy of the program to run, so I've created a function that lists all process's with it's name, and kills all the process's except the one with the lowest PID. In unix that would work for keeping the original process running, but I just found out in windows that this does not work. I'm trying to avoid using a locking method. Does anyone have any ideas. If there was a way to get the current process ID, then I could work with that. Func CheckIfAlreadyRunning() Local $list Local $FirstProcessID = 99999999999999999 $list = ProcessList("IPC_Monitor.exe") for $i = 1 to $list[0][0] ConsoleWrite($list[$i][0] & " " & $list[$i][1] & @CR) If($list[$i][1] < $FirstProcessID) Then $FirstProcessID = $list[$i][1] EndIf next for $i = 1 to $list[0][0] If $list[$i][1] <> $FirstProcessID Then ProcessClose($list[$i][1]) EndIf next EndFunc Link to comment Share on other sites More sharing options...
FuryCell Posted June 26, 2007 Share Posted June 26, 2007 (edited) Take a look at _Singleton() in the helpfile. It should provide the functionally you are looking for. Edited June 26, 2007 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Metaborn Posted June 26, 2007 Author Share Posted June 26, 2007 Take a look at _Singleton() in the helpfile. It should provide the functionally you are looking for.Wow, cool thx. Works like a charmIt's always nice when you don't have to reinvent the wheel Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now