• [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);
    
    
                        }
                    }
  • 相关阅读:
    run C source file like a script
    shared_ptr注意点
    C++ #if #endif #define #ifdef #ifndef #if defined #if !defined详解 (转)
    linux切换g++
    std::forward_list
    有关typename
    win7下 mysql安装(mysql-5.7.18-winx64.zip)
    c++ 库函数返回的字符串指针是否需要手动释放
    c++ const char *[] or char [][]
    校园资源助手
  • 原文地址:https://www.cnblogs.com/wdd812674802/p/10947631.html
Copyright © 2020-2023  润新知