Home
Manage Your Code
Snippet: Start External Application (C#)
Title: Start External Application Language: C#
Description: A simple method of starting an external application Views: 180
Author: Paul Ward Date Added: 5/26/2008
Copy Code  
1[System.Runtime.InteropServices.DllImport("user32.dll")]
2public static extern IntPtr FindWindow(string lpClass, string lpTitle); 
3
4/// <summary>
5/// Starts a specified app if not running
6/// </summary>
7/// <param name="appName">The name of the app</param>
8/// <param name="pathToYourExe">The path to the app exe</param>
9void StartSpp(string appName, string pathToYourExe)
10{
11	if (FindWindow(null, appName) == System.IntPtr.Zero)
12        {
13            Process.Start(pathToYourExe);
14        }    
15}