Browse Source

获取软件信息完善(安装后路径、卸载字符串)

yuzhengyang 6 years ago
parent
commit
9f341539f3

+ 8 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/SoftwareInfo.cs

@@ -23,6 +23,10 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         /// </summary>
         /// </summary>
         public string Publisher { get; set; }
         public string Publisher { get; set; }
         /// <summary>
         /// <summary>
+        /// 安装后路径
+        /// </summary>
+        public string InstallLocation { get; set; }
+        /// <summary>
         /// 帮助链接
         /// 帮助链接
         /// </summary>
         /// </summary>
         public string HelpLink { get; set; }
         public string HelpLink { get; set; }
@@ -31,6 +35,10 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         /// </summary>
         /// </summary>
         public string URLInfoAbout { get; set; }
         public string URLInfoAbout { get; set; }
         /// <summary>
         /// <summary>
+        /// 卸载字符串
+        /// </summary>
+        public string UninstallString { get; set; }
+        /// <summary>
         /// 空间占用
         /// 空间占用
         /// </summary>
         /// </summary>
         public int EstimatedSize { get; set; }
         public int EstimatedSize { get; set; }

+ 4 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/SoftwareTool.cs

@@ -60,11 +60,13 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
 
 
                             string name = SubKey.GetValue("DisplayName", "").ToString();
                             string name = SubKey.GetValue("DisplayName", "").ToString();
                             string pub = SubKey.GetValue("Publisher", "").ToString();
                             string pub = SubKey.GetValue("Publisher", "").ToString();
+                            string installlocation = SubKey.GetValue("InstallLocation", "").ToString();
                             string version = SubKey.GetValue("DisplayVersion", "").ToString();
                             string version = SubKey.GetValue("DisplayVersion", "").ToString();
                             string datestr = SubKey.GetValue("InstallDate", "").ToString();
                             string datestr = SubKey.GetValue("InstallDate", "").ToString();
                             string sizestr = SubKey.GetValue("EstimatedSize", "").ToString();
                             string sizestr = SubKey.GetValue("EstimatedSize", "").ToString();
                             string helpurl = SubKey.GetValue("HelpLink", "").ToString();
                             string helpurl = SubKey.GetValue("HelpLink", "").ToString();
                             string abouturl = SubKey.GetValue("URLInfoAbout", "").ToString();
                             string abouturl = SubKey.GetValue("URLInfoAbout", "").ToString();
+                            string uninstallstring = SubKey.GetValue("UninstallString", "").ToString();
                             DateTime date = DateTime.Parse("2001-10-25");//设置初始值为WindowsXP发布日期
                             DateTime date = DateTime.Parse("2001-10-25");//设置初始值为WindowsXP发布日期
                             DateTime.TryParseExact(datestr, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out date);
                             DateTime.TryParseExact(datestr, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out date);
                             if (date.Year < 2001) date = DateTime.Parse("2001-10-25");
                             if (date.Year < 2001) date = DateTime.Parse("2001-10-25");
@@ -75,11 +77,13 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
                             {
                             {
                                 Name = name,
                                 Name = name,
                                 Publisher = pub,
                                 Publisher = pub,
+                                InstallLocation = installlocation,
                                 Version = version,
                                 Version = version,
                                 InstallDate = date,
                                 InstallDate = date,
                                 EstimatedSize = size,
                                 EstimatedSize = size,
                                 HelpLink = helpurl,
                                 HelpLink = helpurl,
                                 URLInfoAbout = abouturl,
                                 URLInfoAbout = abouturl,
+                                UninstallString = uninstallstring,
                             });
                             });
                         }
                         }
                         SubKey?.Close();
                         SubKey?.Close();

+ 7 - 6
Azylee.Utils/Tests/Test.Toast/Form1.cs

@@ -1,4 +1,5 @@
-using Azylee.WinformSkin.FormUI.Toast;
+using Azylee.Core.WindowsUtils.InfoUtils;
+using Azylee.WinformSkin.FormUI.Toast;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel;
@@ -19,6 +20,11 @@ namespace Test.Toast
             InitializeComponent();
             InitializeComponent();
         }
         }
 
 
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            var x = SoftwareTool.GetControlList();
+        }
+
         private void button1_Click(object sender, EventArgs e)
         private void button1_Click(object sender, EventArgs e)
         {
         {
             ToastForm.Display("中车四方终端准入系统提示", "系统自动检测发现故障,由于准入系统认证组件工作异常,导致无法正常访问网络,需要进行尝试修复,请点击此提示系统自动修复,修复成功后请尝试登录。", ToastType.info, null, 10);
             ToastForm.Display("中车四方终端准入系统提示", "系统自动检测发现故障,由于准入系统认证组件工作异常,导致无法正常访问网络,需要进行尝试修复,请点击此提示系统自动修复,修复成功后请尝试登录。", ToastType.info, null, 10);
@@ -50,11 +56,6 @@ namespace Test.Toast
             ToastForm.Display("中车四方终端准入系统提示", str, ToastType.info, null, 10);
             ToastForm.Display("中车四方终端准入系统提示", str, ToastType.info, null, 10);
         }
         }
 
 
-        private void Form1_Load(object sender, EventArgs e)
-        {
-      
-        }
-
         private void button6_Click(object sender, EventArgs e)
         private void button6_Click(object sender, EventArgs e)
         {
         {
             ToolTipIcon icon = ToolTipIcon.Info;
             ToolTipIcon icon = ToolTipIcon.Info;

+ 4 - 0
Azylee.Utils/Tests/Test.Toast/Test.Toast.csproj

@@ -79,6 +79,10 @@
     <None Include="App.config" />
     <None Include="App.config" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\Azylee.Core\Azylee.Core.csproj">
+      <Project>{88DC61FA-95F0-41B7-9D7D-AB0F3CBD169C}</Project>
+      <Name>Azylee.Core</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\Azylee.WinformSkin\Azylee.WinformSkin.csproj">
     <ProjectReference Include="..\..\Azylee.WinformSkin\Azylee.WinformSkin.csproj">
       <Project>{d280c16f-fde2-4647-bd76-3514f673426d}</Project>
       <Project>{d280c16f-fde2-4647-bd76-3514f673426d}</Project>
       <Name>Azylee.WinformSkin</Name>
       <Name>Azylee.WinformSkin</Name>