public static string GetBrowsers(string strBrowserName)
        {
            RegistryKey browserKeys;
            string      strBrowserVersion = string.Empty;

            //on 64bit the browsers are in a different location
            browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Clients\StartMenuInternet");
            if (browserKeys == null)
            {
                browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet");
            }
            string[] browserNames = browserKeys.GetSubKeyNames();
            var      browsers     = new List <string>();

            for (int i = 0; i < browserNames.Length; i++)
            {
                BrowserUrlTracker browser    = new BrowserUrlTracker();
                RegistryKey       browserKey = browserKeys.OpenSubKey(browserNames[i]);
                browser.Name = (string)browserKey.GetValue(null);
                RegistryKey browserKeyPath = browserKey.OpenSubKey(@"shell\open\command");
                browser.Path = (string)browserKeyPath.GetValue(null).ToString().StripQuotes();
                RegistryKey browserIconPath = browserKey.OpenSubKey(@"DefaultIcon");
                browser.IconPath = (string)browserIconPath.GetValue(null).ToString().StripQuotes();
                if (strBrowserName == browser.Name)
                {
                    if (browser.Path != null)
                    {
                        string[] NewPath   = browser.Path.Split(new string[] { ".exe" }, StringSplitOptions.None);
                        string   FinalPath = NewPath[0] + ".exe";
                        if (FinalPath.Contains("\""))
                        {
                            FinalPath = FinalPath.Substring(1, FinalPath.Length - 1);
                        }
                        browser.Version = FileVersionInfo.GetVersionInfo(FinalPath).FileVersion;
                    }

                    else
                    {
                        browser.Version = "unknown";
                    }

                    strBrowserVersion = browser.Version;
                    break;
                }
            }
            return(strBrowserVersion);
        }
示例#2
0
        public static void fncAppTracker()
        {
            if (GlobalClass.CheckForInternetConnection())
            {
                try
                {
                    string title  = string.Empty;
                    string appexe = string.Empty;

                    IntPtr handle = GetForegroundWindow();
                    if (!handle.Equals(IntPtr.Zero))
                    {
                        int tLength = GetWindowTextLength(handle);
                        if (tLength > 0)
                        {
                            if (tLength > 255)
                            {
                                tLength = 255;
                            }
                            StringBuilder wTitle = new StringBuilder(string.Empty, tLength + 1);
                            if (GetWindowText(handle, wTitle, wTitle.Capacity) > 0)
                            {
                                title = wTitle.ToString();
                            }
                            if (title != OldTitle && !String.IsNullOrEmpty(title))
                            {
                                int wProcID = 0;
                                if (GetWindowThreadProcessId(handle, out wProcID) > 0)
                                {
                                    appexe = Process.GetProcessById(wProcID).ProcessName;
                                }
                                if (!string.IsNullOrEmpty(appexe))
                                {
                                    if (appexe.Equals("firefox"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforFirefox();
                                        //BrowserUrlTracker.ReadBrowserUrlforChrome();
                                    }
                                    else if (appexe.Equals("iexplore"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforIE();
                                    }
                                    else if (appexe.Equals("chrome"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforChrome();
                                    }
                                    else if (appexe.Equals("opera"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforOpera();
                                    }
                                    else
                                    {
                                        OldTitle = title;
                                        appexe   = appexe + ".exe";
                                        WriteData(title, appexe);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message);
                    GlobalClass.WriteTolog("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message);
                }
            }
            else
            {
                GlobalClass.WriteTolog("server not giving any response");
            }
        }