Beispiel #1
0
        private void btnInstallRealPlayer_Click(object sender, System.EventArgs e)
        {
            ProcessStartInfo psi = null;
            Process prc = null;
            try
            {

                //Initialize a process startup info structure
                psi = new ProcessStartInfo();
                psi.FileName = System.IO.Path.Combine(
                                    this.targetDirectory,
                                    "RealPlayer" + System.IO.Path.PathSeparator.ToString() + "RealPlayerSetup.exe"
                                                    );
                psi.ErrorDialog = false;
                psi.WindowStyle = ProcessWindowStyle.Hidden;

                //Start the process configured by this startup-info structure
                prc = new Process();
                prc.StartInfo = psi;
                prc.Start();

                //Wait for it synchronously
                prc.WaitForExit();

            }
            catch(Exception _e)
            {
                //Show customised error dialog box
                frmException frm = new frmException();
                frm.ExceptionDialogTitle = "RealPlayer setup problem ";
                frm.ErrorMessage = _e.Message;
                frm.StrackTrace = _e.StackTrace;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    frm.Dispose();
                    frm = null;
                }
            }
            finally
            {
                if (prc != null)
                {
                    prc.Close();
                }
            }
        }
        private bool IsRealPlayerVersionProper()
        {
            bool versionImproper = false;
            try
            {
                //Get the version form the registry
                RegistryKey rkRealPlayer = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\RealNetworks\RealPlayer");

                //If the key exists then only compare version
                if (rkRealPlayer == null)
                {
                    versionImproper = true;
                }
                else
                {
                    //Registry key valid!
                    //Get the version value
                    System.Version currentVersion = new Version((string)rkRealPlayer.GetValue("version"));
                    System.Version standardVersion = new Version("6.0.12.1056");

                    if (currentVersion < standardVersion)
                    {
                        versionImproper = true;
                    }

                }

            }
            catch(SecurityException se)
            {
                //Show customised error dialog box
                frmException frm = new frmException();
                frm.ExceptionDialogTitle = "Registry access problem ";
                frm.ErrorMessage = se.Message;
                frm.StrackTrace = se.StackTrace;
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    frm.Dispose();
                    frm = null;
                }

                versionImproper = false;
            }
            catch(Exception e)
            {
                versionImproper = false;
            }

            return !versionImproper;
        }