How to Check if App is Already Running.
In order to bring a window upfront you need to mess with win32 API calls - no easy way around (if you know any please give me a shout). Here's how to import the calls we'll be using:
Here's a static method to bring a Window upfront in a given winApp (can be easily integrated with the previous post linked above):
//Win32 API calls to raise a given processs main window
private static extern bool SetForegroundWindow(IntPtr hWnd);
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
private static extern bool IsIconic(IntPtr hWnd);
private const int SW_RESTORE = 9;
That'd be all - knock yourself out (tested on a number of XP and Vista machines).
static class Program
// all the rest of the stuff ... Main other methods etc.
public static void BringOnFront()
Process myProcess = Process.GetCurrentProcess();
string myAsseblyName = Assembly.GetExecutingAssembly().GetName().Name;
foreach (Process processId in Process.GetProcessesByName(myAsseblyName))
if (myProcess.Id != processId.Id)
IntPtr hWnd = processId.MainWindowHandle;