diff --git a/updater/App.config b/updater/App.config new file mode 100644 index 0000000..b50c74f --- /dev/null +++ b/updater/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/updater/Form1.Designer.cs b/updater/Form1.Designer.cs new file mode 100644 index 0000000..220bc48 --- /dev/null +++ b/updater/Form1.Designer.cs @@ -0,0 +1,111 @@ +namespace updater +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.LabelLog = new System.Windows.Forms.Label(); + this.ButtonUpdate = new System.Windows.Forms.Button(); + this.LabelLocalVersion = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.SuspendLayout(); + // + // LabelLog + // + this.LabelLog.BackColor = System.Drawing.SystemColors.ControlLight; + this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.LabelLog.Location = new System.Drawing.Point(52, 52); + this.LabelLog.Name = "LabelLog"; + this.LabelLog.Size = new System.Drawing.Size(340, 100); + this.LabelLog.TabIndex = 0; + this.LabelLog.Text = "正在检测"; + this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.LabelLog.Click += new System.EventHandler(this.LabelLog_Click); + // + // ButtonUpdate + // + this.ButtonUpdate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215))))); + this.ButtonUpdate.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215))))); + this.ButtonUpdate.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Blue; + this.ButtonUpdate.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215))))); + this.ButtonUpdate.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.ButtonUpdate.ForeColor = System.Drawing.Color.White; + this.ButtonUpdate.Location = new System.Drawing.Point(183, 198); + this.ButtonUpdate.Name = "ButtonUpdate"; + this.ButtonUpdate.Size = new System.Drawing.Size(78, 31); + this.ButtonUpdate.TabIndex = 1; + this.ButtonUpdate.Text = "立即更新"; + this.ButtonUpdate.UseVisualStyleBackColor = false; + this.ButtonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click); + // + // LabelLocalVersion + // + this.LabelLocalVersion.Location = new System.Drawing.Point(172, 232); + this.LabelLocalVersion.Name = "LabelLocalVersion"; + this.LabelLocalVersion.Size = new System.Drawing.Size(100, 23); + this.LabelLocalVersion.TabIndex = 2; + this.LabelLocalVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(52, 159); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(340, 10); + this.progressBar1.TabIndex = 3; + this.progressBar1.Visible = false; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(438, 286); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.LabelLocalVersion); + this.Controls.Add(this.ButtonUpdate); + this.Controls.Add(this.LabelLog); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "AI校对王更新"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label LabelLog; + private System.Windows.Forms.Button ButtonUpdate; + private System.Windows.Forms.Label LabelLocalVersion; + private System.Windows.Forms.ProgressBar progressBar1; + } +} + diff --git a/updater/Form1.cs b/updater/Form1.cs new file mode 100644 index 0000000..93286d9 --- /dev/null +++ b/updater/Form1.cs @@ -0,0 +1,204 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing.Design; +using System.IO; +using System.IO.Compression; +using System.Net; +using System.Text; +using System.Web.UI.Design.WebControls; +using System.Windows.Forms; + +namespace updater +{ + public partial class Form1 : Form + { + private int localVersionCode = 0; + private UpdateModel model; + private static string applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; + private string versionFilePath = applicationBase + Path.GetFileName("version.json"); + private string updateDir = applicationBase + "update\\"; + private string updateInfoUri = "https://file.wx.wm-app.xyz/jdw/latest.json"; + private string updateSource; + + public Form1() + { + InitializeComponent(); + string source = File.Exists(versionFilePath) ? File.ReadAllText(versionFilePath) : null; + if (source != null && source.Length > 0) + { + UpdateModel update = JsonConvert.DeserializeObject(source); + this.localVersionCode = update.VersionCode; + LabelLocalVersion.Text = update.Version; + } + } + + + private void ButtonUpdate_Click(object sender, System.EventArgs e) + { + if (CheckHostAppRunning()) + { + return; + } + progressBar1.Visible = true; + if (!Directory.Exists(updateDir)) + { + Directory.CreateDirectory(updateDir); + } + string updateFileName = updateDir + Path.GetFileName(model.UpdateFile); + // 判断是否已经存在升级包 + if (File.Exists(updateFileName)) + { + ExtractUpdatePackage(); + return; + } + DownLoadFile(model.UpdateFile, updateFileName); + } + + public bool CheckHostAppRunning() + { + Process[] array = Process.GetProcesses(); + foreach (Process item2 in array) + { + if (item2.ProcessName.Equals("wps")) + { + MessageBox.Show("检测到 WPS 正在运行中,请关闭后再执行更新操作"); + return true; + } + else if (item2.ProcessName.Equals("WINWORD")) + { + MessageBox.Show("检测到 Word 正在运行中,请关闭后再执行更新操作"); + } + } + return false; + } + + private void LabelLog_Click(object sender, System.EventArgs e) + { + + } + + public void CheckUpdate() + { + HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(updateInfoUri); + HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse(); + // 获取响应内容 + if (resp.StatusCode == HttpStatusCode.OK) + { + Stream receiveStream = resp.GetResponseStream(); + StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); + updateSource = readStream.ReadToEnd(); + if (updateSource == null && updateSource.Length == 0) + { + LabelLog.Text = "获取更新信息失败"; + return; + } + resp.Close(); + UpdateModel update = JsonConvert.DeserializeObject(updateSource); + ProcessUpdate(update); + } + } + + private void ProcessUpdate(UpdateModel update) + { + LabelLog.Text = update.Log; + this.model = update; + if (update.VersionCode > this.localVersionCode) + { + ButtonUpdate.Enabled = true; + } + else + { + ButtonUpdate.Visible = false; + LabelLocalVersion.Text = "当前是最新版本"; + } + } + + private void Form1_Load(object sender, EventArgs e) + { + ButtonUpdate.Enabled = false; + CheckUpdate(); + + } + + public void DownLoadFile(string url, string filename) + { + try + { + WebClient client = new WebClient(); + Uri uri = new Uri(url); + + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback); + client.DownloadFileAsync(uri, filename); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } + + private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e) + { + this.BeginInvoke(new Action(() => + { + progressBar1.Value = e.ProgressPercentage; + })); + } + private void DownloadFileCallback(object sender, AsyncCompletedEventArgs e) + { + this.BeginInvoke(new Action(() => + { + ExtractUpdatePackage(); + })); + } + + private void ExtractUpdatePackage() + { + progressBar1.Value = 100; + string zipFilePath = updateDir + Path.GetFileName(model.UpdateFile); + // 可以考虑备份旧文件 + //string destinationFolder = Path.Combine(applicationBase, "update\\old"); + //CopyDirectory(applicationBase, destinationFolder); + //ZipFile.ExtractToDirectory(zipFilePath, applicationBase); + using (ZipArchive zip = ZipFile.OpenRead(zipFilePath)) + { + foreach (ZipArchiveEntry entry in zip.Entries) + { + // 采用覆盖模式进行解压 + entry.ExtractToFile(Path.Combine(applicationBase, entry.FullName), true); + } + } + MessageBox.Show("更新完成"); + // 保存日志 + File.WriteAllText(versionFilePath, updateSource); + this.Close(); + } + public static void CopyDirectory(string sourceFolder, string destinationFolder) + { + Directory.CreateDirectory(destinationFolder); + string moduleName = Process.GetCurrentProcess().MainModule.ModuleName; + FileSystemInfo[] fileSystemInfos = new DirectoryInfo(sourceFolder).GetFileSystemInfos(); + foreach (FileSystemInfo fileSystemInfo in fileSystemInfos) + { + if (fileSystemInfo is DirectoryInfo) + { + if (fileSystemInfo.Name != "update" && fileSystemInfo.Name != "logs") + { + if (!Directory.Exists(destinationFolder + "\\" + fileSystemInfo.Name)) + { + Directory.CreateDirectory(destinationFolder + "\\" + fileSystemInfo.Name); + } + CopyDirectory(fileSystemInfo.FullName, destinationFolder + "\\" + fileSystemInfo.Name); + } + } + else if (!fileSystemInfo.FullName.EndsWith(moduleName)) + { + File.Copy(fileSystemInfo.FullName, destinationFolder + "\\" + fileSystemInfo.Name, overwrite: true); + } + } + } + } +} diff --git a/updater/Form1.resx b/updater/Form1.resx new file mode 100644 index 0000000..a4b6ac6 --- /dev/null +++ b/updater/Form1.resx @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAAAAAAA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 + POYUWQBkqae3rKE8IfREdY6gq1FWA7Mn4aED4BlBNgS4x0WlVwRss43sZAGQ5VoeXImo77moXqoq6xje + 1WiiphXvVuF+ha1brnvw0N+tvY+p998Y9iEw42ABkAN2PNxApKQNNFIY7yn9cOD82wXeT/p2M2oHHhXk + rqSffCmpqu+/zlbfzQUWADnm1XtvZTCaqIn7wZcRbkI5j9O/PjCoyBNeJLFRh2K/i8fiQ1fYsts5xQIg + B7VsasB3KsmIV6/oWuBaTm03owD4E8qdgfMei/rxriUr7cTPRRYAOaxp8xpUg4h43lJgPfBxRt/NaD/Q + CGyuGSze1xuN6yUNdnU/V1kA5IHnH7gJRUvi0eDPUV0PLOO9tx13AT9EuYOo95wmJVi+0u7Pz3UWAHmi + pXEV06WNt7RuGnANw6sVn8nwbbp/8J1s8MV7QlX7F66+P+xyzSSxAMgzzZtX4wcqiaic5zlZhXDAed7D + Z/Vd3fpy+Y+44mvfCrtEM4ksAPLUzjtvRVSica8/8DXqzlpn3/Pz0f8Dz/Ipj9Lf07UAAAAASUVORK5C + YII= + + + \ No newline at end of file diff --git a/updater/OfficeKiller.cs b/updater/OfficeKiller.cs new file mode 100644 index 0000000..1ec90d3 --- /dev/null +++ b/updater/OfficeKiller.cs @@ -0,0 +1,42 @@ +using System.Diagnostics; + +namespace updater +{ + public class OfficeKiller + { + public void KillWordProcess() + { + Process[] processesByName = Process.GetProcessesByName("WINWORD"); + foreach (Process obj in processesByName) + { + UpdateData.GetInstance().ShouldRebootMSOffice = true; + obj.Kill(); + obj.WaitForExit(); + } + } + + public void KillExcelProcess() + { + Process[] processesByName = Process.GetProcessesByName("EXCEL"); + foreach (Process obj in processesByName) + { + obj.Kill(); + obj.WaitForExit(); + } + } + + public void KillWPSProcess() + { + Process[] processesByName = Process.GetProcessesByName("wps"); + foreach (Process process in processesByName) + { + UpdateData.GetInstance().ShouldRebootWPS = true; + if (!process.HasExited) + { + process.Kill(); + process.WaitForExit(); + } + } + } + } +} diff --git a/updater/OfficeStarter.cs b/updater/OfficeStarter.cs new file mode 100644 index 0000000..96f4bb8 --- /dev/null +++ b/updater/OfficeStarter.cs @@ -0,0 +1,57 @@ +using Microsoft.Win32; +using System.Diagnostics; + +namespace updater +{ + public class OfficeStarter + { + public void StartWPS() + { + if (UpdateData.GetInstance().ShouldRebootWPS) + { + string text = RegistHelper.GetRegistData(Registry.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Kingsoft Office", "DisplayIcon"); + if (string.IsNullOrWhiteSpace(text)) + { + text = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Kingsoft Office", "DisplayIcon"); + } + if (!string.IsNullOrWhiteSpace(text)) + { + text = text.Substring(0, text.LastIndexOf("WPS Office")) + "WPS Office\\ksolaunch.exe"; + Process.Start(text); + } + } + } + + public void StartMSOffice() + { + if (UpdateData.GetInstance().ShouldRebootMSOffice) + { + string allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\16.0\\Word\\InstallRoot", "Path"); + //检查2016 / 2019 / 365版本路径 + if (string.IsNullOrWhiteSpace(allRegistData)) + { + allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\15.0\\Common\\InstallRoot", "Path"); + // 检查2013版本路径 + } + if (string.IsNullOrWhiteSpace(allRegistData)) + { + allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\14.0\\Common\\InstallRoot", "Path"); + // 检查2010版本路径 + } + if (string.IsNullOrWhiteSpace(allRegistData)) + { + allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\12.0\\Common\\InstallRoot", "Path"); + //检查2007版本路径 + } + if (!string.IsNullOrWhiteSpace(allRegistData)) + { + allRegistData += "WINWORD.exe"; + //MSOffice启动路径 + Process.Start(allRegistData); + } + // 未能从注册表找到MS Office 安装路径 + // 没有找到 直接不处理了 + } + } + } +} diff --git a/updater/Program.cs b/updater/Program.cs new file mode 100644 index 0000000..023de71 --- /dev/null +++ b/updater/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace updater +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/updater/Properties/AssemblyInfo.cs b/updater/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2b4efe0 --- /dev/null +++ b/updater/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("AI校对王UPDATER")] +[assembly: AssemblyDescription("AI校对王更新程序")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("果麦文化")] +[assembly: AssemblyProduct("AI校对王")] +[assembly: AssemblyCopyright("Copyright © 果麦文化 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("73ac658d-cd49-4731-8491-a7bdbc811559")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/updater/Properties/Resources.Designer.cs b/updater/Properties/Resources.Designer.cs new file mode 100644 index 0000000..bc9adc2 --- /dev/null +++ b/updater/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace updater.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("updater.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/updater/Properties/Resources.resx b/updater/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/updater/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/updater/Properties/Settings.Designer.cs b/updater/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8131288 --- /dev/null +++ b/updater/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace updater.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/updater/Properties/Settings.settings b/updater/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/updater/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/updater/Properties/app.manifest b/updater/Properties/app.manifest new file mode 100644 index 0000000..5a95963 --- /dev/null +++ b/updater/Properties/app.manifest @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/updater/RegistHelper.cs b/updater/RegistHelper.cs new file mode 100644 index 0000000..b655bfe --- /dev/null +++ b/updater/RegistHelper.cs @@ -0,0 +1,52 @@ +using Microsoft.Win32; +namespace updater +{ + internal class RegistHelper + { + public static string GetRegistData(RegistryKey rtype, string path, string name) + { + RegistryKey registryKey = rtype.OpenSubKey(path, writable: false); + if (registryKey != null) + { + if (registryKey.GetValue(name) != null) + { + return registryKey.GetValue(name).ToString(); + } + return string.Empty; + } + return string.Empty; + } + + public static string GetAllRegistData(RegistryHive rtype, string path, string name) + { + RegistryKey registryKey = RegistryKey.OpenBaseKey(rtype, RegistryView.Registry32).OpenSubKey(path); + if (registryKey == null) + { + registryKey = RegistryKey.OpenBaseKey(rtype, RegistryView.Registry64).OpenSubKey(path); + } + if (registryKey != null) + { + return registryKey.GetValue(name).ToString(); + } + return string.Empty; + } + + public static void WriteCURegedit(string name, string tovalue) + { + Registry.CurrentUser.OpenSubKey("SOFTWARE", writable: true).CreateSubKey("mine\\WordAddInTest1").SetValue(name, tovalue); + } + + public static void DeleteCURegist(string name) + { + RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", writable: true).OpenSubKey("mine\\WordAddInTest1", writable: true); + string[] subKeyNames = registryKey.GetSubKeyNames(); + for (int i = 0; i < subKeyNames.Length; i++) + { + if (subKeyNames[i] == name) + { + registryKey.DeleteSubKeyTree(name); + } + } + } + } +} diff --git a/updater/UpdateData.cs b/updater/UpdateData.cs new file mode 100644 index 0000000..1a9c2c3 --- /dev/null +++ b/updater/UpdateData.cs @@ -0,0 +1,22 @@ +namespace updater +{ + public class UpdateData + { + private static UpdateData instance; + + public string CurrentVersion { get; set; } + public string LatestVersion { get; set; } + + public bool ShouldRebootMSOffice { get; set; } + public bool ShouldRebootWPS { get; set; } + + public static UpdateData GetInstance() + { + if (instance == null) + { + instance = new UpdateData(); + } + return instance; + } + } +} diff --git a/updater/UpdateModel.cs b/updater/UpdateModel.cs new file mode 100644 index 0000000..163393d --- /dev/null +++ b/updater/UpdateModel.cs @@ -0,0 +1,10 @@ +namespace updater +{ + public class UpdateModel + { + public int VersionCode { get; set; } + public string Version { get; set; } + public string Log { get; set; } + public string UpdateFile { get; set; } + } +} diff --git a/updater/av802-h1xg6-001.ico b/updater/av802-h1xg6-001.ico new file mode 100644 index 0000000..ed9fb25 Binary files /dev/null and b/updater/av802-h1xg6-001.ico differ diff --git a/updater/packages.config b/updater/packages.config new file mode 100644 index 0000000..ea29129 --- /dev/null +++ b/updater/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/updater/updater.csproj b/updater/updater.csproj new file mode 100644 index 0000000..3cd409a --- /dev/null +++ b/updater/updater.csproj @@ -0,0 +1,118 @@ + + + + + Debug + AnyCPU + {73AC658D-CD49-4731-8491-A7BDBC811559} + WinExe + updater + updater + v4.6.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + av802-h1xg6-001.ico + + + LocalIntranet + + + false + + + Properties\app.manifest + + + + False + D:\libs\CSharp_AntdUI\net46\AntdUI.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + \ No newline at end of file