private void btnStartApp_Click(object sender, EventArgs e)
        {
            IDocument doc = null;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                switch (cboApps.SelectedItem.ToString())
                {
                case "ArcMap":
                    doc = new ESRI.ArcGIS.ArcMapUI.MxDocumentClass();
                    break;

                case "ArcScene":
                    doc = new ESRI.ArcGIS.ArcScene.SxDocumentClass();
                    break;

                case "ArcGlobe":
                    doc = new ESRI.ArcGIS.ArcGlobe.GMxDocumentClass();
                    break;
                }
            }
            catch { } //Fail if you haven't installed the target application
            finally
            {
                this.Cursor = Cursors.Default;
            }

            if (doc != null)
            {
                //Advanced (AppROT event): Handle manual shutdown, comment out if not needed
                m_appROTEvent             = new AppROTClass();
                m_appROTEvent.AppRemoved += new IAppROTEvents_AppRemovedEventHandler(m_appROTEvent_AppRemoved);

                //Get a reference of the application and make it visible
                m_application         = doc.Parent;
                m_application.Visible = true;
                m_appHWnd             = m_application.hWnd;

                //Enable/disable controls accordingly
                txtShapeFilePath.Enabled = true;
                btnShutdown.Enabled      = true;
                btnDrive.Enabled         = ShouldEnableAddLayer;
                cboApps.Enabled          = btnStartApp.Enabled = false;
            }
            else
            {
                m_appROTEvent = null;
                m_application = null;

                txtShapeFilePath.Enabled = false;
                btnShutdown.Enabled      = btnDrive.Enabled = false;
                cboApps.Enabled          = btnStartApp.Enabled = true;
            }
        }
        private void btnStartApp_Click(object sender, EventArgs e)
        {
            IDocument doc = null;
            try
            {
                this.Cursor = Cursors.WaitCursor;
                switch (cboApps.SelectedItem.ToString())
                {
                    case "ArcMap":
                        doc = new ESRI.ArcGIS.ArcMapUI.MxDocumentClass();
                        break;
                    case "ArcScene":
                        doc = new ESRI.ArcGIS.ArcScene.SxDocumentClass();
                        break;
                    case "ArcGlobe":
                        doc = new ESRI.ArcGIS.ArcGlobe.GMxDocumentClass();
                        break;
                }
            }
            catch { } //Fail if you haven't installed the target application
            finally
            {
                this.Cursor = Cursors.Default;
            }

            if (doc != null)
            {
                //Advanced (AppROT event): Handle manual shutdown, comment out if not needed
                m_appROTEvent = new AppROTClass();
                m_appROTEvent.AppRemoved += new IAppROTEvents_AppRemovedEventHandler(m_appROTEvent_AppRemoved);

                //Get a reference of the application and make it visible
                m_application = doc.Parent;
                m_application.Visible = true;
                m_appHWnd = m_application.hWnd;

                //Enable/disable controls accordingly
                txtShapeFilePath.Enabled = true;
                btnShutdown.Enabled = true;
                btnDrive.Enabled = ShouldEnableAddLayer;
                cboApps.Enabled = btnStartApp.Enabled = false;
            }
            else
            {
                m_appROTEvent = null;
                m_application = null;

                txtShapeFilePath.Enabled = false;
                btnShutdown.Enabled = btnDrive.Enabled = false;
                cboApps.Enabled = btnStartApp.Enabled = true;
            }
        }