Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Sep 15, 2019 9:22 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Application - Already Running
PostPosted: Tue Jan 31, 2012 11:43 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Hello
I wanted to share how to detect if your app is already running.
To prevent two copies from running at the same time.

This example is based on the App.PrevInstance in VB6 URL below.
[url]
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
[/url]

Hope this helps!

1. Make a property in your Apps Class called AppMutex
2. Make a method in your Apps Class called PrevInstance
3. Add the codes below to the Apps Open/Close events

Sub PrevInstance() As Boolean
AppMutex = New Mutex( App.ExecutableFile.Name )

If Not AppMutex.TryEnter Then
Return True
Else
Return False
End
End Sub


Apps Open Event
If App.PrevInstance = True Then
MsgBox("The application is already running!")
Quit
End


Apps Close Event
AppMutex.Leave


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group