Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to detect the launched appliction?

How to detect the launched appliction?

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    azusakt
    wrote on last edited by
    #1

    Hi All, I would like to know, how can I detect whether an application is already launched? I need to enable some function according to this checking, can some people help? thanks so much.

    L J 2 Replies Last reply
    0
    • A azusakt

      Hi All, I would like to know, how can I detect whether an application is already launched? I need to enable some function according to this checking, can some people help? thanks so much.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      The preliminary question is: how do you identify your app? You could use Process.GetProcessesByName() to check for a specific process name; process names normally get derived from the EXE's file name (which can easily be modified!). A more reliable approach, if you are the author of the app, is by using a system resource (e.g. a Mutex) with a chosen system-wide name; you then check for the existence of that Mutex. This is how "single instance applications" normally do it. You may want to read this: A Pure .NET Single Instance Application Solution[^] or some similar article. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      A 1 Reply Last reply
      0
      • A azusakt

        Hi All, I would like to know, how can I detect whether an application is already launched? I need to enable some function according to this checking, can some people help? thanks so much.

        J Offline
        J Offline
        JR212
        wrote on last edited by
        #3

        application event:

        Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
        End Sub

        can that help?

        1 Reply Last reply
        0
        • L Luc Pattyn

          The preliminary question is: how do you identify your app? You could use Process.GetProcessesByName() to check for a specific process name; process names normally get derived from the EXE's file name (which can easily be modified!). A more reliable approach, if you are the author of the app, is by using a system resource (e.g. a Mutex) with a chosen system-wide name; you then check for the existence of that Mutex. This is how "single instance applications" normally do it. You may want to read this: A Pure .NET Single Instance Application Solution[^] or some similar article. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          A Offline
          A Offline
          azusakt
          wrote on last edited by
          #4

          Thanks for your infomation, Luc. I'm using your approach, and it works fine. I just got another question, if the PC is a remote server that different user may login to the server and launching the same application. May I use the same function to detect what specific user is launing the application ? thanks

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups