コード例 #1
0
        private static CTM_WebBrowser findFirefoxBrowser()
        {
            CTM_WebBrowser browser = new CTM_WebBrowser();
            browser.setInternalName("firefox");
            browser.setPrettyName("Mozilla Firefox");
            browser.setProcessName("firefox");

            String versionData = null;

            // Windows 7 Compatibility.
            String appManifestFile = CTM_WebBrowser_Factory.findFirefoxBrowserApplicationManifest();

            if (versionData == null && appManifestFile != null)
            {
                // Version=3.6.12
                CTM_Ini appManifest = new CTM_Ini(appManifestFile);
                versionData = appManifest.ReadValue("App", "Version");
            }

            RegistryKey dkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Mozilla\\Mozilla Firefox");
            if (versionData == null && dkey != null)
            {
                versionData = dkey.GetValue("CurrentVersion").ToString();
            }

            if (versionData != null)
            {
                Regex versionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)");
                Match versionMatch = versionRegex.Match(versionData);
                if (versionMatch != null)
                {
                    browser.setIsAvailable(true);
                    browser.setMajor(Convert.ToInt32(versionMatch.Groups["major"].Value));
                    browser.setMinor(Convert.ToInt32(versionMatch.Groups["minor"].Value));
                    browser.setPatch(Convert.ToInt32(versionMatch.Groups["patch"].Value));
                }
            }
            return browser;
        }
コード例 #2
0
        private static CTM_WebBrowser findIEBrowser()
        {
            CTM_WebBrowser browser = new CTM_WebBrowser();
            browser.setInternalName("iexplore");
            browser.setPrettyName("Internet Explorer");
            browser.setProcessName("iexplore");

            RegistryKey dkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer");
            if (dkey != null)
            {
                string bVersion = dkey.GetValue("Version").ToString();
                if (bVersion != null)
                {
                    Regex versionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)");
                    Match versionMatch = versionRegex.Match(bVersion);
                    if (versionMatch.Success)
                    {
                        browser.setIsAvailable(true);
                        browser.setMajor(Convert.ToInt32(versionMatch.Groups["major"].Value));
                        browser.setMinor(Convert.ToInt32(versionMatch.Groups["minor"].Value));
                        browser.setPatch(Convert.ToInt32(versionMatch.Groups["patch"].Value));

                    }
                }
            }
            return browser;
        }
コード例 #3
0
        private static CTM_WebBrowser findSafariBrowser()
        {
            CTM_WebBrowser browser = new CTM_WebBrowser();
            browser.setInternalName("safari");
            browser.setPrettyName("Safari");

            RegistryKey dkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Apple Computer, Inc.\\Safari");
            if (dkey != null)
            {
                string bVersion = dkey.GetValue("Version").ToString();
                if (bVersion != null)
                {
                    Regex versionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\.\d+");
                    Match versionMatch = versionRegex.Match(bVersion);
                    if (versionMatch.Success)
                    {
                        browser.setIsAvailable(true);
                        browser.setMajor(Convert.ToInt32(versionMatch.Groups["major"].Value));
                        browser.setMinor(Convert.ToInt32(versionMatch.Groups["minor"].Value));
                        browser.setPatch(Convert.ToInt32(versionMatch.Groups["patch"].Value));
                    }
                }
            }
            return browser;
        }
コード例 #4
0
        private static CTM_WebBrowser findGoogleChromeBrowser()
        {
            CTM_WebBrowser browser = new CTM_WebBrowser();
            browser.setInternalName("googlechrome");
            browser.setPrettyName("Google Chrome");

            try
            {
                DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome\\Application");

                DirectoryInfo[] dirs = di.GetDirectories("*.*.*.*");

                Regex versionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\.\d+");

                foreach (DirectoryInfo diNext in dirs)
                {
                    Match versionMatch = versionRegex.Match(diNext.Name);
                    if (versionMatch.Success)
                    {
                        browser.setIsAvailable(true);
                        browser.setMajor(Convert.ToInt32(versionMatch.Groups["major"].Value));
                        browser.setMinor(Convert.ToInt32(versionMatch.Groups["minor"].Value));
                        browser.setPatch(Convert.ToInt32(versionMatch.Groups["patch"].Value));
                    }
                }
            }
            catch
            {
                browser.setIsAvailable(false);
            }

            return browser;
        }