|
-
Jul 8th, 2005, 12:12 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] only allow ONE instance of my program
Many programs can only be run one instance at a time. (for example, MSN or AIM messengers) How do they do this, and how can I make my program be like this too?
 Base 2
Fcnncu"Nqxgu"Lguug##
-
Jul 8th, 2005, 12:22 PM
#2
Re: only allow ONE instance of my program
VB Code:
Private Sub Form_Load()
If App.PrevInstance = True Then
Msgbox "Application Already Running"
Unload Me
End Sub
-
Jul 8th, 2005, 12:29 PM
#3
Hyperactive Member
Re: only allow ONE instance of my program
VB Code:
If App.PrevInstance = True Then
MsgBox "This program is already running !", vbCritical, "Fallout[]"
End
End if
-
Jul 8th, 2005, 12:40 PM
#4
Fanatic Member
Re: only allow ONE instance of my program
Here's a tip: if this program is security intensive, then App.PrevInstance will not do a good job. All the person has to do to override App.PrevInstance is change the file's name to something else and run it again :P.
Use the FindWindow API to get the hWnd of the previous instance using the Caption of the main form. If the hWnd is found, then shut down the current instance. This method is a bit harder to override because you would need to hex-edit the program in order to change the caption of the main form.
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Jul 8th, 2005, 12:52 PM
#5
Thread Starter
Hyperactive Member
Re: only allow ONE instance of my program
 Base 2
Fcnncu"Nqxgu"Lguug##
-
Jul 8th, 2005, 08:16 PM
#6
Re: [RESOLVED] only allow ONE instance of my program
Take a look at this and in the Frequently Asked Question link below my sig.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|