Beispiel #1
0
        public Form1()
        {
            //MessageBox.Show(Environment.Is64BitOperatingSystem.ToString());
            // check os
            Version v   = System.Environment.OSVersion.Version;
            double  ver = v.Major + v.Minor / 10.0;


            if (ver <= 6.0)
            {
                MessageBox.Show("This software only run on Windows 7 or later!!!");
                Environment.Exit(0);
                return;
            }

            if (!IsRunAsAdmin())
            {
                // Launch itself as administrator
                ProcessStartInfo proc = new ProcessStartInfo();
                proc.UseShellExecute  = true;
                proc.WorkingDirectory = Environment.CurrentDirectory;
                proc.FileName         = Application.ExecutablePath;
                proc.Verb             = "runas";
                try
                {
                    Process.Start(proc);
                }
                catch (Exception ex)
                {
                    // The user refused to allow privileges elevation.
                    // Do nothing and return directly ...
                }

                Environment.Exit(0);  // Quit itself
                return;
            }
            InitializeComponent();
            if (DwmIsCompositionEnabled())
            {
                MARGINS m = new MARGINS();
                m.Right = m.Bottom = -1;
                m.Left  = m.Top = -1;// this.Width + this.Height;
                DwmExtendFrameIntoClientArea(this.Handle, ref m);
            }
            bgWorker = new BGWorkReport(ReportProcess);

            backgroundWorker1.RunWorkerAsync();
            this.BringToFront();
        }
Beispiel #2
0
        public Form1()
        {
            //MessageBox.Show(Environment.Is64BitOperatingSystem.ToString());
            // check os
            Version v = System.Environment.OSVersion.Version;
            double ver = v.Major + v.Minor / 10.0;

            if (ver <= 6.0)
            {
                MessageBox.Show("This software only run on Windows 7 or later!!!");
                Environment.Exit(0);
                return;
            }

            if (!IsRunAsAdmin())
            {
                // Launch itself as administrator
                ProcessStartInfo proc = new ProcessStartInfo();
                proc.UseShellExecute = true;
                proc.WorkingDirectory = Environment.CurrentDirectory;
                proc.FileName = Application.ExecutablePath;
                proc.Verb = "runas";
                try
                {
                    Process.Start(proc);

                }
                catch(Exception ex)
                {
                    // The user refused to allow privileges elevation.
                    // Do nothing and return directly ...

                }

                Environment.Exit(0);  // Quit itself
                return;
            }
            InitializeComponent();
            if (DwmIsCompositionEnabled())
            {
                MARGINS m = new MARGINS();
                m.Right = m.Bottom = -1;
                m.Left = m.Top = -1;// this.Width + this.Height;
                DwmExtendFrameIntoClientArea(this.Handle, ref m);
            }
            bgWorker = new BGWorkReport(ReportProcess);

            backgroundWorker1.RunWorkerAsync();
            this.BringToFront();
        }