Projects

Find all our projects in development below.
All source code is GNU General Public License (GPL)

javaCamViewer

Browsing javaCamViewer/AppLauncher.cs (1.18 KB)

using System;
using System.Runtime.InteropServices;

namespace javaCamViewer
{
    public class AppLauncher
    {
        [DllImport("shell32", EntryPoint = "ShellExecuteA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
	    private static extern int ShellExecute(int hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);

	    private string appPath;
	    private string appArgs;
	    private SHOWWINDOW_STYLES appShow;

	    public enum SHOWWINDOW_STYLES
	    {
		    SW_SHOWHIDDEN = 0,
		    SW_SHOWNORMAL = 1,
		    SW_SHOWMINIMIZED = 2,
		    SW_SHOWMAXIMIZED = 3
	    }

	    public AppLauncher(string sPath, string sArgs, SHOWWINDOW_STYLES iShow)
	    {
		    appPath = sPath;
		    appArgs = sArgs;
		    appShow = iShow;
	    }

	    public void runApp()
	    {
		    // use ShellExecute api to run app
		    ShellExecute(0, null, appPath, appArgs, this.getPath(), (int)appShow);
	    }

	    private string getPath()
	    {
		    if (appPath.IndexOf("\\") >= 0) {
			    return appPath.Substring(0, appPath.LastIndexOf("\\"));
		    } else {
			    return appPath;
		    }
	    }
    }
}

Download javaCamViewer/AppLauncher.cs

Back to file list


Back to project page