It is currently Thu May 23, 2013 7:07 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: One copy of the program?
PostPosted: Thu Nov 10, 2011 9:21 am 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 13, 2007 12:42 pm
Posts: 1307
Location: Manchester, UK
Which is fine for Windows, but not Linux.


Top
 Profile  
 
 Post subject: Re: One copy of the program?
PostPosted: Fri Nov 11, 2011 8:06 am 
Offline
New User
New User

Joined: Fri Nov 11, 2011 7:58 am
Posts: 6
Check proccess list to find running copy
run ps -aux (linux/macosx) or tasklist (windows, may be blocked by admin or viruses) in hte hidden console and try to find unique application name in console output


Top
 Profile  
 
 Post subject: Re: One copy of the program?
PostPosted: Fri Nov 11, 2011 2:35 pm 
Offline
User
User
User avatar

Joined: Mon Apr 04, 2011 3:56 am
Posts: 48
Location: Russia,Angarsk
Compile and try to run twice.
Code:
Procedure GetRunningProgramm(prog.s)
     Protected RegEx.i = CreateRegularExpression(#PB_Any, "[0-9]+")
     Protected Directory.s = "/proc"
     Protected ExamDir.i = ExamineDirectory(#PB_Any, Directory, "*.*")
     Protected OutFile.i
     Protected Sum.i=0
     If RegEx And ExamDir
          While NextDirectoryEntry(ExamDir)
               If MatchRegularExpression(RegEx, DirectoryEntryName(ExamDir))
                    OutFile = ReadFile(#PB_Any,Directory+"/"+DirectoryEntryName(ExamDir)+"/cmdline")
                    If  OutFile
                         If FindString(ReadString(OutFile), prog, 1)
                              Sum + 1
                         EndIf
                         CloseFile(OutFile)
                    EndIf
               EndIf
          Wend
          FinishDirectory(ExamDir)
     EndIf
     ProcedureReturn Sum
EndProcedure

If GetRunningProgramm(ProgramFilename())>1
     MessageRequester("","yes working")
Else
     MessageRequester("","no working")
EndIf


ps -aux Works on the same principle :?:

_________________
Linux Mint Maya(Mate), x86, PureBasic 5.00(5.10b1)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye