From e1c650a74f4f1fdfde8965f759986462d2ba4c77 Mon Sep 17 00:00:00 2001 From: liukaiyuan Date: Fri, 23 Feb 2024 02:17:01 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LKY_OfficeTools/Common/Com_NetworkOS.cs | 132 ------------------------ LKY_OfficeTools/Common/Com_SystemOS.cs | 120 --------------------- LKY_OfficeTools/OfficeTools.cs | 4 +- LKY_OfficeTools/Resource/LKY_Cert.cer | Bin 848 -> 0 bytes 4 files changed, 2 insertions(+), 254 deletions(-) delete mode 100644 LKY_OfficeTools/Resource/LKY_Cert.cer diff --git a/LKY_OfficeTools/Common/Com_NetworkOS.cs b/LKY_OfficeTools/Common/Com_NetworkOS.cs index d78d27c..6c63998 100644 --- a/LKY_OfficeTools/Common/Com_NetworkOS.cs +++ b/LKY_OfficeTools/Common/Com_NetworkOS.cs @@ -31,137 +31,5 @@ internal static bool IsConnected } } } - - internal class IP - { - internal static string GetMyIP_Info() - { - try - { - string ip = GetMyIP(); - if (string.IsNullOrEmpty(ip)) - { - //没获取到IP,则返回未知 - ip = "ip_unknow"; - } - - string ip_location = IP2Location(); - if (string.IsNullOrEmpty(ip_location)) - { - //没获取到归属地,则返回未知 - ip_location = "location_unknow"; - } - - return $"{ip} ({ip_location})"; - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - //意外失败,返回error - return "ip_info_error!"; - } - } - - internal static string GetMyIP() - { - try - { - //截取服务器列表 - string ip_server_info = Com_TextOS.GetCenterText(AppJson.Info, "\"IP_Check_Url_List\": \"", "\""); - - //遍历获取ip - if (!string.IsNullOrEmpty(ip_server_info)) - { - List ip_server = new List(ip_server_info.Split(';')); - foreach (var now_server in ip_server) - { - //获取成功时结束,否则遍历获取 - string my_ip_page = Com_WebOS.Visit_WebClient(now_server.Replace(" ", "")); //替换下无用的空格字符后访问Web - string my_ip = GetIPFromHtml(my_ip_page); - if (string.IsNullOrEmpty(my_ip)) - { - //获取失败则继续遍历 - continue; - } - else - { - return my_ip; - } - } - //始终没获取到IP,则返回null - return null; - } - else - { - //获取失败时,使用默认值 - string req_url = "http://www.net.cn/static/customercare/yourip.asp"; - string my_ip_page = Com_WebOS.Visit_WebClient(req_url); - return GetIPFromHtml(my_ip_page); - } - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - return null; - } - } - - internal static string IP2Location() - { - try - { - string req_url = $"https://{DateTime.UtcNow.Year}.ip138.com"; - - //访问页面 - string ip_page = Com_WebOS.Visit_WebClient(req_url); - - //页面非空判断 - if (string.IsNullOrEmpty(ip_page)) - { - throw new Exception(); - } - - //拆解html - string ip_location = Com_TextOS.GetCenterText(ip_page, "来自:", "

").Replace("\r", "").Replace("\n", ""); - - //解析非空判断 - if (string.IsNullOrEmpty(ip_location)) - { - throw new Exception(); - } - - //无任何问题,直接返回该值 - return ip_location; - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - return null; - } - } - - private static string GetIPFromHtml(string pageHtml) - { - try - { - //验证ipv4地址 - string reg = @"(?:(?:(25[0-5])|(2[0-4]\d)|((1\d{2})|([1-9]?\d)))\.){3}(?:(25[0-5])|(2[0-4]\d)|((1\d{2})|([1-9]?\d)))"; - string ip = ""; - Match m = Regex.Match(pageHtml, reg); - if (m.Success) - { - ip = m.Value; - } - return ip; - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - return null; - } - } - - - } } } diff --git a/LKY_OfficeTools/Common/Com_SystemOS.cs b/LKY_OfficeTools/Common/Com_SystemOS.cs index ab5b196..8ef16e4 100644 --- a/LKY_OfficeTools/Common/Com_SystemOS.cs +++ b/LKY_OfficeTools/Common/Com_SystemOS.cs @@ -9,11 +9,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; -using System.Drawing.Imaging; using System.IO; -using System.Linq; -using System.Windows.Forms; using static LKY_OfficeTools.Lib.Lib_AppLog; namespace LKY_OfficeTools.Common @@ -315,121 +311,5 @@ internal static bool ExportReg(string reg_path, string save_to) } } } - - internal class SoftWare - { - public static List InstalledList() - { - try - { - //从注册表中获取控制面板“卸载程序”中的程序和功能列表 - RegistryKey HK_Root_x32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); //打开x32系统键 - RegistryKey HK_Root_x64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); //打开x64系统键 - - string soft_path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - RegistryKey software_x32_list = HK_Root_x32.OpenSubKey(soft_path); //x32软件列表 - RegistryKey software_x64_list = null; //x64软件列表。x32系统该值将始终为null - - //获取x64软件列表(仅在用户系统是x64的情况下获取) - if (Environment.Is64BitOperatingSystem) - { - software_x64_list = HK_Root_x64.OpenSubKey(soft_path); - } - - //整合键位 - List software_key = new List(); - if (software_x32_list != null && software_x32_list.SubKeyCount > 0) - { - software_key.Add(software_x32_list); - } - if (software_x64_list != null && software_x64_list.SubKeyCount > 0) - { - software_key.Add(software_x64_list); - } - - //开始获取 - if (software_key != null && software_key.Count > 0) - { - List software_info = new List(); - - foreach (var now_bit in software_key) //遍历2个系统位数的注册表 - { - foreach (string now_subkeyname in now_bit.GetSubKeyNames()) //遍历每个位数下面,对应的软件列表 - { - //打开对应的软件名称 - RegistryKey SubKey = now_bit.OpenSubKey(now_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); - } - } - } - } - - //元素去重 - if (software_info != null && software_info.Count > 0) - { - return software_info.Distinct().ToList(); - } - } - - return null; - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - return null; - } - } - } - - internal class Screen - { - internal static bool CaptureToSave(string save_to, ImageFormat file_type = null) - { - try - { - //初始化屏幕尺寸 - int screenLeft = SystemInformation.VirtualScreen.Left; - int screenTop = SystemInformation.VirtualScreen.Top; - int screenWidth = SystemInformation.VirtualScreen.Width; - int screenHeight = SystemInformation.VirtualScreen.Height; - - //接收截图 - using (Bitmap bmp = new Bitmap(screenWidth, screenHeight)) - { - //抓取 - using (Graphics g = Graphics.FromImage(bmp)) - { - g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size); - } - - //判断保存格式 - if (file_type == null) - { - file_type = ImageFormat.Jpeg; - } - - //创建日志目录 - Directory.CreateDirectory(new FileInfo(save_to).DirectoryName); - - bmp.Save(save_to, file_type); - } - - return true; - } - catch (Exception Ex) - { - new Log(Ex.ToString()); - return false; - } - } - } } } \ No newline at end of file diff --git a/LKY_OfficeTools/OfficeTools.cs b/LKY_OfficeTools/OfficeTools.cs index 1ca3ca6..4492521 100644 --- a/LKY_OfficeTools/OfficeTools.cs +++ b/LKY_OfficeTools/OfficeTools.cs @@ -40,8 +40,8 @@ private static void Entry() //欢迎话术 Console.Title = $"{AppAttribute.AppName} v{AppAttribute.AppVersion}"; new Log($"{AppAttribute.AppName} [版本 {AppAttribute.AppVersion}]\n" + - $"版权所有(C)LiuKaiyuan (Odysseus.Yuan)。保留所有权利。\n\n" + - $"探讨 {AppAttribute.AppName} 相关内容,可发送邮件至:OdysseusYuan@foxmail.com", ConsoleColor.Gray); + $"版权所有(C)LiuKaiyuan (Odysseus.Yuan)。保留所有权利。\n\n" + + $"探讨 {AppAttribute.AppName} 相关内容,可发送邮件至:OdysseusYuan@foxmail.com", ConsoleColor.Gray); //清理冗余信息 Log.Clean(); diff --git a/LKY_OfficeTools/Resource/LKY_Cert.cer b/LKY_OfficeTools/Resource/LKY_Cert.cer deleted file mode 100644 index 42f441e74f820a9712193bd1c347c9379bface7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 848 zcmXqLV)ij;V%oZZnTe5!NuYbZmymNt;bQlYTEAyE|E)FPW#iOp^Jx3d%gD&W%3#pg zY$#yB$HpAW!XeD=l$x29nU`+JXTSpzVH0L`&dAJ5G*mWF1o63qrF=3=y%RGlOB3@H zH2hO4i;GiBi}fObTunn&17*0;oQz^(Ihm!|5Ty>qStX@L-yn?;H98e19~83U22rKx4qAaP~meB{t$WMyD(>;;BkCsSi1 z!$m7!%{9#(JO8nTH!$^iEc~TZE6eJ}^~aye{gS=5UX)((FfRY`huK*(Ckibp zme9M;Z?Ia2)u(gP_0a2qJG63UrVAy-^hwE0;>Zp>BcSfQa)0mJsbAcF1`AKfEIa?m VJtFVg9+~?YovVWm7)j}z0sz~8B5nWx