App Running ?

Developed or developing a new product in PureBasic? Tell the world about it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

I released a new LIBRARY with only one new Function for Purebasic-Windows-Version.
Its Called AppRunning(Appname.s) and its tells you if one or more instances of your exe are already running.It depends not on Windows, so you can use it also with Console-appz and different EXE also .
The Complete LIB/Function comes with Purebasic.example,readymade EXE and a full documented Sourcecode (only 60 lines) in NASM-Assembler-Syntax.

download on the resourcesite in the asm-lib sections or directly

under

http://www.reelmediaproductions.com/pb/ ... unning.zip


Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

Very nice example to learn writing a library, thx for sharing Rings.
And a cool new function also :)

Regards,

Berikco

http://www.benny.zeb.be
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

I did a update,hope that is soon available on the resourcesite
(if paul beats the Dragon :) )
I have done a bugfixing and a bit renaming (thx Danilo for you Hints!)
so if you update , delete the older 'app' library in Purebasic-Userlibraries directory first!



Its a long way to the top if you wanna .....CodeGuru
zapman*
Enthusiast
Enthusiast
Posts: 115
Joined: Wed Jun 02, 2004 10:17 pm
Location: New Caledonia (South Pacific)
Contact:

Post by zapman* »

The zip pointed by the link seems to be incompleted (error while opening the file)

So, I find a shorter solution:

Code: Select all

#ProgName = "MyProgram"
;
Procedure IsLaunched (Name$)
  Handle=0
  Hwnd = FindWindow_( 0, 0 )
  While Hwnd <> 0
    Txt.s = Space(256)
    GetWindowText_(Hwnd, Txt, 256)
    Hwnd = GetWindow_(Hwnd, #GW_HWNDNEXT)
    If Left(Txt,Len(nom$)) = Name$
      Handle=Hwnd
      Hwnd=0
    EndIf
  Wend
  ProcedureReturn (Handle)
EndProcedure
;
If IsLaunched (#ProgName)
  End
EndIf

OpenWindow(0,PosX,PosY,420,280,#PB_Window_ScreenCentered,#ProgName)
....
....

Don't try - DO it !
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Checking by the window name is not 100% foolproof. Some people use
apps which change the window title (such as adding date/time) and thus
two or more instances of your app will be able to be run if you check by
name alone. For 100% accuracy, you need to use a mutex, which is in
the FAQ ( viewtopic.php?t=4876 ).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi PB,

OT, but the request is not important enough to create a wishlist thread.

Can you use your mod powers to make all the Questions in the FAQ bold, so they stand out? Just a little nicety.

Thanks!
@}--`--,-- A rose by any other name ..
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Can you use your mod powers to make all the Questions in the FAQ
> bold, so they stand out? Just a little nicety.

Okay, on the weekend I'll see how I can improve the FAQ (probably with
some more questions/answers too).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

PB wrote:Okay, on the weekend I'll see how I can improve the FAQ (probably with some more questions/answers too).
Champion! Thanks. :)
@}--`--,-- A rose by any other name ..
Post Reply