[Gambas-user] Avoiding multiple instances
Stefano Palmeri
rospolosco at ...152...
Fri Feb 1 11:15:31 CET 2008
Alle 18:38, giovedì 31 gennaio 2008, Epíleg ha scritto:
> En/na Stefano Palmeri ha escrit:
> > Alle 16:45, giovedì 31 gennaio 2008, Stefano Palmeri ha scritto:
> >> I use this simple code:
> >>
> >> PUBLIC SUB Main()
> >>
> >> DIM sShellOutput AS String
> >>
> >> SHELL "ps aux | grep " & Application.Name & ".gambas" & " | grep -v
> >> grep" TO sShellOutput
> >>
> >> IF sShellOutput THEN QUIT
> >>
> >> END
> >
> > or better:
> >
> > PUBLIC SUB Main()
> >
> > DIM sShellOutput AS String
> >
> > SHELL "ps aux | grep " & Application.Name & ".gambas" &
> > " | grep -wv grep | wc -l" TO sShellOutput
> >
> > IF Val(sShellOutput) > 1 THEN QUIT
> >
> > END
>
> Very good solution. Thanks a lot!
>
> Epíleg.
>
I found out that using Application.Args[0] is better,
because we don't have to care if the user renames the binary.
PUBLIC SUB Main()
DIM sShellOutput AS String
SHELL "ps aux | grep -w " & Application.Args[0]&
" | grep -wv grep | wc -l" TO sShellOutput
IF Val(sShellOutput) > 1 THEN QUIT
END
Stefano
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list