I have created single instance windows application, when i minimize the window app goes to system tray. Now i want to restore it from system tray without making double click on notifyicon ( i can use Run Window , Or desktop shortcut)
Below is my code
[STAThread]
static void Main()
{
bool createdNew = true;
using (Mutex mutex = new Mutex(true, "frm_takescreens", out createdNew))
{
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
const string REGISTRY_KEY = @"HKEY_CURRENT_USER\Toposcreen";
const string REGISTY_VALUE = "FirstRun";
if (Convert.ToInt32(Microsoft.Win32.Registry.GetValue(REGISTRY_KEY, REGISTY_VALUE, 0)) == 0)
{
Microsoft.Win32.Registry.SetValue(REGISTRY_KEY, REGISTY_VALUE, 1, Microsoft.Win32.RegistryValueKind.DWord);
Application.Run(new frm_dir());
}
else
{
Application.Run(new frm_mdi());
}
}
else
{
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
{
if (process.Id != current.Id)
{
SetForegroundWindow(process.MainWindowHandle);
break;
}
}
}
}
}