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. C#
  4. Single Instance

Single Instance

Scheduled Pinned Locked Moved C#
questionsysadminhelp
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
    AB7771
    wrote on last edited by
    #1

    Hi all, I have an application which will be installed on the user machine. The application has two main parts. First application checks for the new updates from the server and then invokes the other application using the dll. The second application is what the user actually interact with. The application minimizes to the system tray. The user may close or minimize the form that is displayed. My main objective here is if the application is running and the user again clicks on the Shortcut that is placed on the desktop. The form that is minimized or was closed should be displayed. How do i do this? Hope i have put the problem properly to everyones understanding.

    Thanks & Regards, Pramod "Everyone is a genius at least once a year"

    K S 2 Replies Last reply
    0
    • A AB7771

      Hi all, I have an application which will be installed on the user machine. The application has two main parts. First application checks for the new updates from the server and then invokes the other application using the dll. The second application is what the user actually interact with. The application minimizes to the system tray. The user may close or minimize the form that is displayed. My main objective here is if the application is running and the user again clicks on the Shortcut that is placed on the desktop. The form that is minimized or was closed should be displayed. How do i do this? Hope i have put the problem properly to everyones understanding.

      Thanks & Regards, Pramod "Everyone is a genius at least once a year"

      K Offline
      K Offline
      Kodanda Pani
      wrote on last edited by
      #2

      Hi Yadav Guess the following 2 links will help you. http://msdn.microsoft.com/msdnmag/issues/05/09/NETMatters/ http://www.codeproject.com/threads/simplesingleinstanceapp.asp Thanks and Regards Pani

      A 1 Reply Last reply
      0
      • K Kodanda Pani

        Hi Yadav Guess the following 2 links will help you. http://msdn.microsoft.com/msdnmag/issues/05/09/NETMatters/ http://www.codeproject.com/threads/simplesingleinstanceapp.asp Thanks and Regards Pani

        A Offline
        A Offline
        AB7771
        wrote on last edited by
        #3

        Thanks for the links...But I have to display a form from another assembly...

        Thanks & Regards, Pramod "Everyone is a genius at least once a year"

        1 Reply Last reply
        0
        • A AB7771

          Hi all, I have an application which will be installed on the user machine. The application has two main parts. First application checks for the new updates from the server and then invokes the other application using the dll. The second application is what the user actually interact with. The application minimizes to the system tray. The user may close or minimize the form that is displayed. My main objective here is if the application is running and the user again clicks on the Shortcut that is placed on the desktop. The form that is minimized or was closed should be displayed. How do i do this? Hope i have put the problem properly to everyones understanding.

          Thanks & Regards, Pramod "Everyone is a genius at least once a year"

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          Does the shortcut point to the actual application or the "launcher" application? Either way, you could check for the existence of the process first off and switch focus to it if you find it running. Something like

          bool IsProcessAlreadyRunning(string processName)
          {
          Process[] processes = Process.GetProcesses(processName);
          return (processes != null && processes.Length != 0);
          }

          If the above method returns true, you know that an instance of the process is already running. You could then use the MainWindowHandle[^] of the corresponding Process object to get the window handle and P/Invoke some Win32 API (Activate?) to bring the existing process' window into focus. Hope this helps.

          Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

          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