restoring window minimzed to the system tray?

  • Thread starter Thread starter Mark Smith
  • Start date Start date
M

Mark Smith

I have an app that minimizes itself to the system tray. It's also
single instance; when a second instance is started, it just activates
the first one and quits.

When the first instance isn't in the system tray, I can use
ShowWindowAsync() via interop to bring it to the front. When it's
minimzed to the system tray, nothing seems to restore it back to a
window. I've tried all the obvious variations of SW_SHOW, SW_RESTORE,
etc. Has anyone gotten this to work?
 
try this out

using System.Runtime.InteropServices;

#region Check for existing Instance
// get the name of our process
string proc=Process.GetCurrentProcess().ProcessName;
// get the list of all processes by that name
Process[] processes=Process.GetProcessesByName(proc);
// if there is more than one process...
if (processes.Length > 1)
{
MessageBox.Show("Already One Instance of this Application is
running.\nPlease check in the system Tray.\nThis Instance will Exit
now.");
// exit our process
Application.ExitThread();

}
#endregion
 
Back
Top