Skip to content

Commit

Permalink
已解决因当前系统 Office 架构不同,而导致不能安装的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusYuan committed Nov 7, 2022
1 parent eeba3bf commit f097372
Show file tree
Hide file tree
Showing 77 changed files with 1,648 additions and 54 deletions.
6 changes: 0 additions & 6 deletions LKY_OfficeTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D00F508-106A-42D1-BE0F-048762434E69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D00F508-106A-42D1-BE0F-048762434E69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D00F508-106A-42D1-BE0F-048762434E69}.Debug|x86.ActiveCfg = Debug|x86
{6D00F508-106A-42D1-BE0F-048762434E69}.Debug|x86.Build.0 = Debug|x86
{6D00F508-106A-42D1-BE0F-048762434E69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D00F508-106A-42D1-BE0F-048762434E69}.Release|Any CPU.Build.0 = Release|Any CPU
{6D00F508-106A-42D1-BE0F-048762434E69}.Release|x86.ActiveCfg = Release|x86
{6D00F508-106A-42D1-BE0F-048762434E69}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 4 additions & 3 deletions LKY_OfficeTools/Common/Com_EmailOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ internal static bool Send_Localhost()
/// <param name="SMTPHost">smtp服务器</param>
/// <param name="SMTPuser">邮箱</param>
/// <param name="SMTPpass">密码</param>
/// <param name="priority">邮件优先级,默认为一般,设置为高时,收件人看到标题旁边,会有红色叹号</param>
/// <returns></returns>
public static bool Send_Account( string send_from_username, string send_to_mail, string mail_subject,
string mail_body, string mail_file, string SMTPHost, string SMTPuser, string SMTPpass)
string mail_body, string mail_file, string SMTPHost, string SMTPuser, string SMTPpass, MailPriority priority = MailPriority.Normal)
{
////设置from和to地址
MailAddress from = new MailAddress(SMTPuser, send_from_username);
Expand Down Expand Up @@ -117,8 +118,8 @@ public static bool Send_Account( string send_from_username, string send_to_mail,
////邮件采用的编码
oMail.BodyEncoding = Encoding.UTF8;

////设置邮件的优先级为高
oMail.Priority = MailPriority.High;
////设置邮件的优先级
oMail.Priority = priority;

////发送邮件
SmtpClient client = new SmtpClient();
Expand Down
109 changes: 98 additions & 11 deletions LKY_OfficeTools/Common/Com_SystemOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using static LKY_OfficeTools.Lib.Lib_OfficeInfo;

namespace LKY_OfficeTools.Common
{
Expand All @@ -19,7 +20,7 @@ internal class Com_SystemOS
/// <summary>
/// 系统级别类库
/// </summary>
internal class OS
internal class OSVersion
{
/// <summary>
/// 操作系统类别枚举
Expand Down Expand Up @@ -99,11 +100,7 @@ internal static OSType GetPublishType()
else if (ver.Major == 10 && ver.Minor == 0) //正确获取win10版本号,需要在exe里面加入app.manifest
{
//检查注册表,因为win10和11的主版本号都为10,只能用buildID来判断了
RegistryKey HKLM = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32); //判断操作系统版本(64位\32位)打开注册表项,不然 x86编译的本程序 读取 x64的程序会出现无法读取 已经存在于注册表 中的数据
string reg_path = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
RegistryKey office_reg = HKLM.OpenSubKey(reg_path);
string curr_ver = office_reg.GetValue("CurrentBuild").ToString();
string curr_ver = Registry.GetValue(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild");

if (!string.IsNullOrEmpty(curr_ver) && int.Parse(curr_ver) < 22000) //Win11目前内部版本号
{
Expand Down Expand Up @@ -134,11 +131,7 @@ internal static string GetBuildNumber(bool isCoreVersion = true)
try
{
//检查注册表
RegistryKey HKLM = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32); //判断操作系统版本(64位\32位)打开注册表项,不然 x86编译的本程序 读取 x64的程序会出现无法读取 已经存在于注册表 中的数据
string reg_path = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
RegistryKey office_reg = HKLM.OpenSubKey(reg_path);
string curr_mode = office_reg.GetValue("CurrentBuild").ToString();
string curr_mode = Registry.GetValue(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild");

//为空返回未知
if (string.IsNullOrEmpty(curr_mode))
Expand All @@ -162,5 +155,99 @@ internal static string GetBuildNumber(bool isCoreVersion = true)
}
}
}

/// <summary>
/// 注册表操作类库
/// </summary>
internal class Registry
{
/// <summary>
/// 获取指定路径下的注册表键值。
/// 默认注册表根部项为 HKLM
/// </summary>
/// <returns></returns>
internal static string GetValue(string path, string key, RegistryHive root = RegistryHive.LocalMachine)
{
try
{
RegistryKey HK_Root = RegistryKey.OpenBaseKey(root,
Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32); //判断操作系统版本(64位\32位)打开注册表项,不然 x86编译的本程序 读取 x64的程序会出现无法读取 已经存在于注册表 中的数据

RegistryKey path_reg = HK_Root.OpenSubKey(path); //先获取路径

if (path_reg == null)
{
//找不到注册表路径
return null;
}
else
{
object value = path_reg.GetValue(key);
if (value != null) //必须先判断不为null,否则会抛出异常
{
//一切正常
return value.ToString();
}
else
{
//Key不存在或值为空
return null;
}
}
}
catch
{
return null;
}
}
}

/// <summary>
/// 软件操作类库
/// </summary>
internal class SoftWare
{
/// <summary>
/// 获取已安装软件列表
/// </summary>
/// <returns></returns>
public static List<string> GetList()
{
try
{
//从注册表中获取控制面板“卸载程序”中的程序和功能列表
RegistryKey Key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
if (Key != null) //如果系统禁止访问则返回null
{
List<string> software_info = new List<string>();

foreach (string SubKeyName in Key.GetSubKeyNames())
{
//打开对应的软件名称
RegistryKey SubKey = Key.OpenSubKey(SubKeyName);
if (SubKey != null)
{
string DisplayName = SubKey.GetValue("DisplayName", "NONE").ToString();

//过滤条件
if (DisplayName != "NONE" && !DisplayName.Contains("vs") && !DisplayName.Contains("Visual C++") &&
!DisplayName.Contains(".NET"))
{
software_info.Add(DisplayName);
}
}
}

return software_info;
}
return null;
}
catch
{
return null;
}
}
}
}
}
5 changes: 3 additions & 2 deletions LKY_OfficeTools/Example/LKY_OfficeTools_AppInfo.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"Latest_Version": "1.0.3.21107",
"Latest_Version_Update_Url": "https://gitee.com/OdysseusYuan/LKY_OfficeTools/releases/download/AppInfo/LKY_OfficeTools_v1.0.3.21107.zip",
"Latest_Version": "1.0.4.21108",
"Latest_Version_Update_Url": "https://gitee.com/OdysseusYuan/LKY_OfficeTools/releases/download/AppInfo/LKY_OfficeTools_v1.0.4.21108.zip",

"Count_Url": "https://odysseusyuan.gitee.io/lky_officetools/running_count.html",
"Count_Feedback_To": "[email protected]",
"Count_Feedback_From": "[email protected]",
"Count_Feedback_Pwd": "vecxfbuynacedaag",

"Pop_Office_ID": "ProPlus2021Volume",
"KMS_List": "kms.03k.org, kms.chinancce.com, zh.us.to, kms.shuax.com, kms.dwhd.org, kms.luody.info, kms.digiboy.ir, kms.lotro.cc, www.zgbs.cc, cy2617.jios.org",

"IP_Check_Url_List": "http://www.net.cn/static/customercare/yourip.asp; https://ip.tool.chinaz.com; https://tool.lu/ip; https://www.ip123.in; https://www.ip123.in"
Expand Down
Loading

0 comments on commit f097372

Please sign in to comment.