ATMLUtilitiesLibrary.UTRSOfficeUtils.IsInstalled C# (CSharp) Метод

IsInstalled() публичный статический Метод

public static IsInstalled ( MSOfficeApplications app ) : bool
app MSOfficeApplications
Результат bool
        public static bool IsInstalled( MSOfficeApplications app )
        {
            string keyName = String.Empty;
            switch (app)
            {
                case MSOfficeApplications.Access:
                    keyName = "Access.Application";
                    break;
                case MSOfficeApplications.Excel:
                    keyName = "Excel.Application";
                    break;
                case MSOfficeApplications.Word:
                    keyName = "Word.Application";
                    break;
                case MSOfficeApplications.PowerPoint:
                    keyName = "PowerPoint.Application";
                    break;
                case MSOfficeApplications.Outlook:
                    keyName = "Outlook.Application";
                    break;
            }

            RegistryKey key = Registry.ClassesRoot;
            RegistryKey subKey = key.OpenSubKey( keyName );
            return ( subKey != null );
        }

Usage Example

Пример #1
0
        private ATMLContext()
        {
            //---------------------------------------------------------------------//
            //--- We will try the registry first for the database location      ---//
            //--- This way the installed database may be bypassed - primarily   ---//
            //--- for development reasons.                                      ---//
            //---------------------------------------------------------------------//
            LoadDatabasePathFromRegistry();

            //---------------------------------------------------------------------//
            //--- Under normal conditions we'll get the database path from the  ---//
            //--- common application data folder created for this application.  ---//
            //---------------------------------------------------------------------//
            LoadDatabasePathFromInstallationDataPath();

            _msWordInstalled       = UTRSOfficeUtils.IsInstalled(UTRSOfficeUtils.MSOfficeApplications.Word);
            _msExcelInstalled      = UTRSOfficeUtils.IsInstalled(UTRSOfficeUtils.MSOfficeApplications.Excel);
            _msAccessInstalled     = UTRSOfficeUtils.IsInstalled(UTRSOfficeUtils.MSOfficeApplications.Access);
            _msPowerPointInstalled = UTRSOfficeUtils.IsInstalled(UTRSOfficeUtils.MSOfficeApplications.PowerPoint);
            _msOutlookInstalled    = UTRSOfficeUtils.IsInstalled(UTRSOfficeUtils.MSOfficeApplications.Outlook);
        }