restoring window minimzed to the system tray?

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?
 
M

MailInterface

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top