コード例 #1
0
        private void InstallVC2010()
        {
            VC2010Install dialog = new VC2010Install();

            dialog.TopMost = true;

            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                throw new System.Configuration.Install.InstallException("VC++ 2010 x86 Runtime were not installed, aborting installation.");
            }


            //Debugger.Break();
            //SetWindowPos(Process.GetCurrentProcess().MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW);

            //if (MessageBox.Show("Visual C++ 2010 x86 Runtime is not installed or needs to be updated. Please select OK to download and install the VC++ 2010 Runtimes from: http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe.", "VC++ 2010 Runtime Required", MessageBoxButtons.OKCancel) != DialogResult.OK)
            //{
            //    if(MessageBox.Show("Would you like to continue without installing the VC++ 2010 x86 Runtime (You can install it later if you wish)?", "Skip VC++ 2010 Runtimes?", MessageBoxButtons.YesNo) == DialogResult.No)
            //        throw new System.Configuration.Install.InstallException("VC++ 2010 x86 Runtime were not installed, aborting installation.");
            //}

            //WebClient webClient = new WebClient();
            //string tempFile = Path.Combine(Path.GetTempPath(), "vcredist_x86.exe");

            //if (File.Exists(tempFile) == true)
            //    File.Delete(tempFile);

            //try
            //{
            //    webClient.DownloadFile("http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe", tempFile);

            //    if (File.Exists(tempFile) == true)
            //    {
            //        var process = Process.Start(tempFile);

            //        Log.Write("process.MainWindowHandle: " + process.MainWindowHandle);


            //        SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW);
            //        SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);

            //        //this.SendToBack();
            //        //this.WindowState = FormWindowState.Minimized;
            //        //this.WindowState = FormWindowState.Normal;
            //        //this.BringToFront();


            //        process.WaitForExit();
            //    }
            //}
            //catch
            //{
            //    if (File.Exists(tempFile) == true)
            //        File.Delete(tempFile);
            //}
            //finally
            //{
            //    SetWindowPos(Process.GetCurrentProcess().MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
            //}
        }
コード例 #2
0
        private void InstallVC2010()
        {
            VC2010Install dialog = new VC2010Install();
            dialog.TopMost = true;

            if(dialog.ShowDialog() == DialogResult.Cancel)
                throw new System.Configuration.Install.InstallException("VC++ 2010 x86 Runtime were not installed, aborting installation.");

            //Debugger.Break();
            //SetWindowPos(Process.GetCurrentProcess().MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW);

            //if (MessageBox.Show("Visual C++ 2010 x86 Runtime is not installed or needs to be updated. Please select OK to download and install the VC++ 2010 Runtimes from: http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe.", "VC++ 2010 Runtime Required", MessageBoxButtons.OKCancel) != DialogResult.OK)
            //{
            //    if(MessageBox.Show("Would you like to continue without installing the VC++ 2010 x86 Runtime (You can install it later if you wish)?", "Skip VC++ 2010 Runtimes?", MessageBoxButtons.YesNo) == DialogResult.No)
            //        throw new System.Configuration.Install.InstallException("VC++ 2010 x86 Runtime were not installed, aborting installation.");
            //}

            //WebClient webClient = new WebClient();
            //string tempFile = Path.Combine(Path.GetTempPath(), "vcredist_x86.exe");

            //if (File.Exists(tempFile) == true)
            //    File.Delete(tempFile);

            //try
            //{
            //    webClient.DownloadFile("http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe", tempFile);

            //    if (File.Exists(tempFile) == true)
            //    {
            //        var process = Process.Start(tempFile);

            //        Log.Write("process.MainWindowHandle: " + process.MainWindowHandle);

            //        SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW);
            //        SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);

            //        //this.SendToBack();
            //        //this.WindowState = FormWindowState.Minimized;
            //        //this.WindowState = FormWindowState.Normal;
            //        //this.BringToFront();

            //        process.WaitForExit();
            //    }
            //}
            //catch
            //{
            //    if (File.Exists(tempFile) == true)
            //        File.Delete(tempFile);
            //}
            //finally
            //{
            //    SetWindowPos(Process.GetCurrentProcess().MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
            //}
        }