Return to an already open application when a user tries to open a new instance

This has been a problem that I haven't been able to figure out for sometime. Preventing the second instance is trivial and has many methods, however, bringing back the already running process isn't. I would like to:

  • Minimized: Undo the minimize and bring the running instance to the front.
  • Behind other windows: Bring the application to the front.
  • The language I am using this in is VB.NET and C#.


    I found this code to be useful. It does the detection and optional activation of an existing application:

    http://www.codeproject.com/KB/cs/cssingprocess.aspx


    If you're using .NET, this seems easier and more straightforward using build-in .NET functionality:

    The Weekly Source Code 31- Single Instance WinForms and Microsoft.VisualBasic.dll


    These link may be of help:

    http://www.ai.uga.edu/mc/SingleInstance.html

    It has code to detect another instance running, not sure what you can do with it once you've got the instance though.

    链接地址: http://www.djcxy.com/p/51178.html

    上一篇: 如何通过批处理脚本检查进程是否正在运行

    下一篇: 用户尝试打开新实例时返回到已打开的应用程序