//通过注册表访问安装路径
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);
}
}