Results 1 to 15 of 15

Thread: [02/03] How to set application run at once?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Question [02/03] How to set application run at once?

    Hello expert.. hope you could help me with my problem...
    I need a code that would make my application run only once..
    once my application is running is shouldn't be open again..
    and also.. when other application is open together with my application
    and then user try to open my application again.. it should focus on my application without opening a new one..

    thanks... hope you could help me..

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [02/03] How to set application run at once?

    Project-->Properties-->Application-->Make single instance application

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Smile Re: [02/03] How to set application run at once?

    thanks.. but there's not option for "Make single instance application" in application properties

  4. #4

  5. #5

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Re: [02/03] How to set application run at once?

    I have already check that thread but still doesn't help me due to im working with vb .net 2003... dey have discussed more on 2005 or higher version... thats why i couldnt relate.. pls guys.. help me.. thanks thanks!

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [02/03] How to set application run at once?

    download vb2008 express. its free.

  8. #8

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Re: [02/03] How to set application run at once?

    Yes.. but the problem is my application doesn't focus if there are other application opened..

  10. #10
    Member
    Join Date
    Dec 2007
    Location
    Indonesia
    Posts
    56

    Re: [02/03] How to set application run at once?

    try like the below code
    Code:
     Dim procs As Process() = Process.GetProcesses()
            For Each proc As Process In procs
                    If proc.MainWindowHandle <> IntPtr.Zero Then
                    SetForegroundWindow(proc.MainWindowHandle)
                    Application.Exit()
                    Exit Sub
                End If
            Next proc

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Re: [02/03] How to set application run at once?

    It has an error on proc.MainWindowHandle <> IntPtr.Zero...
    i think MainWindowHandle is not a member of the Process class

  12. #12
    Member
    Join Date
    Dec 2007
    Location
    Indonesia
    Posts
    56

    Re: [02/03] How to set application run at once?

    use proc.MainWindowTitle and assigned with your application title
    for example proc.MainWindowTitle = "Windows Application1"

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jun 2008
    Posts
    16

    Re: [02/03] How to set application run at once?

    proc.MainWindowTitle is a read only property

  14. #14
    Member
    Join Date
    Dec 2007
    Location
    Indonesia
    Posts
    56

    Re: [02/03] How to set application run at once?

    Code:
    If proc.MainWindowTitle = "Windows Application1" Then
    .....
    end if
    Last edited by hiesan; Aug 20th, 2008 at 04:52 AM.

  15. #15
    Member
    Join Date
    Dec 2007
    Location
    Indonesia
    Posts
    56

    Re: [02/03] How to set application run at once?

    --deleted--
    Last edited by hiesan; Aug 20th, 2008 at 04:53 AM.

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