Results 1 to 6 of 6

Thread: [RESOLVED] only allow ONE instance of my program

  1. #1

    Thread Starter
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Resolved [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##

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: only allow ONE instance of my program

    VB Code:
    1. Private Sub Form_Load()
    2. If App.PrevInstance = True Then
    3. Msgbox "Application Already Running"
    4. Unload Me
    5. End Sub

  3. #3
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    348

    Re: only allow ONE instance of my program

    VB Code:
    1. If App.PrevInstance = True Then
    2.  MsgBox "This program is already running !", vbCritical, "Fallout[]"
    3. End
    4. End if

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    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


  5. #5

    Thread Starter
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Re: only allow ONE instance of my program

    Wow, thank you all.

    Base 2
    Fcnncu"Nqxgu"Lguug##

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] only allow ONE instance of my program

    Take a look at this and in the Frequently Asked Question link below my sig.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width