zoukankan      html  css  js  c++  java
  • [WPF]当前exe打开外部exe(项目更新功能)

    //通过注册表访问安装路径
                    string RegeditKey = "PMSApp";
                    RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);
                    RegistryKey software = key.CreateSubKey(RegeditKey);
                    //本机版本号
                    string setup = Convert.ToString(software.GetValue("DisplayVersion"));
    
                    //判断不相等
                    if (res.CompareTo(setup) > 0)
                    {
                        MessageBoxResult dr = Xceed.Wpf.Toolkit.MessageBox.Show("系统已更新,是否需要更新?", "更新提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
    
                        if (dr == MessageBoxResult.OK)
                        {
                            //确定按钮的方法
                            string strPathExe = software.GetValue("UpdateString").ToString();
                            Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = strPathExe;
                            process.StartInfo.Arguments = null;//-s -t 可以用来关机、开机或重启
                            process.StartInfo.UseShellExecute = false;
                            process.StartInfo.RedirectStandardInput = false;  //true
                            process.StartInfo.RedirectStandardOutput = false;  //true
                            process.StartInfo.RedirectStandardError = false;
                            process.StartInfo.CreateNoWindow = false;
                            process.Start();//启动
    
                            process.CloseMainWindow();//通过向进程的主窗口发送关闭消息来关闭拥有用户界面的进程
                            process.Close();//释放与此组件关联的所有资源
                            System.Environment.Exit(0);
    
    
                        }
                    }
  • 相关阅读:
    90. 子集 II 回溯算法
    47. 全排列 II 回溯算法
    40. 组合总和 II
    39. 组合总和 回溯
    NLP 第八课 语言技术-文本与LDA主题模型
    36. 有效的数独
    31. 下一个排列
    HDU 4527
    HDU 4521
    HDU 5191
  • 原文地址:https://www.cnblogs.com/wdd812674802/p/10947631.html
Copyright © 2011-2022 走看看