diff --git a/ReadMe.md b/ReadMe.md index 331f807..1dc4296 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -17,6 +17,10 @@ C# WinRAR 简体中文-商业版 提取器 #### 更新日志 +2023-06-30 发布v1.0.0.4 +1. 增加版本日期递减枚举检测功能,以应付6.22版本生成日期与下载日期不同步问题。 + (直接检测文件是否能正常下载,缺点是启动会稍微慢一点) + 2022-08-21 发布v1.0.0.3 1. 修复新版x32位程序信息无法获取问题。 2. 修复中文授权信息出现问号问题。 diff --git a/WinRAR-Extractor/HttpWebHelper.cs b/WinRAR-Extractor/HttpWebHelper.cs index 1fbc1ae..f346249 100644 --- a/WinRAR-Extractor/HttpWebHelper.cs +++ b/WinRAR-Extractor/HttpWebHelper.cs @@ -119,6 +119,86 @@ public static string GetHttpWebData(string url, int? timeout, string userAgent, } } + /// + /// 创建GET方式的HTTP请求 + /// + /// 请求的URL + /// 请求的超时时间 + /// 请求的客户端浏览器信息,可以为空 + /// 随同HTTP请求发送的Cookie信息,如果不需要身份验证可以为空 + /// + public static bool GetHttpCheck(string url, int? timeout, string userAgent, bool lastModified = false) + { + lock (_lotGetLocker) + { + HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; + + try + { + if (string.IsNullOrEmpty(url)) + { + throw new ArgumentNullException("url"); + } + + //如果是发送HTTPS请求 + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + // 请求前设置一下使用的安全协议类型 + ServicePointManager.DefaultConnectionLimit = 512; + ServicePointManager.Expect100Continue = true; + ServicePointManager.CheckCertificateRevocationList = false; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + } + + request.Method = "GET"; + request.UserAgent = DefaultUserAgent; + request.Accept = "text/html"; + request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9"); + request.AllowAutoRedirect = true; + request.KeepAlive = false; + if (!string.IsNullOrEmpty(userAgent)) + { + request.UserAgent = userAgent; + } + if (timeout.HasValue) + { + request.Timeout = timeout.Value; + } + request.CookieContainer = new CookieContainer(); + + //获取网页响应结果 + //while (response == null || response.StatusCode != HttpStatusCode.OK) + //{ + // if (Config.IsAppExit) return string.Empty; + + // response = request.GetResponse() as HttpWebResponse; + //} + using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) + { + // 获取HttpWebResponse数据 + if (response != null && response.StatusCode == HttpStatusCode.OK) + { + response.Close(); + response.Dispose(); + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + //Config.logProc.WriteLine(ex.Message); + if (request != null) request.Abort(); + return false; + } + finally + { + if (request != null) request.Abort(); + } + return true; + } + } + //该方法用于验证服务器证书是否合法,当然可以直接返回true来表示验证永远通过。服务器证书具体内容在参数certificate中。可根据个人需求验证 //该方法在request.GetResponse()时触发 private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) diff --git a/WinRAR-Extractor/Properties/AssemblyInfo.cs b/WinRAR-Extractor/Properties/AssemblyInfo.cs index 123f165..3acaaba 100644 --- a/WinRAR-Extractor/Properties/AssemblyInfo.cs +++ b/WinRAR-Extractor/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.3")] -[assembly: AssemblyFileVersion("1.0.0.3")] +[assembly: AssemblyVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.0.4")] diff --git a/WinRAR-Extractor/frmExtractor.cs b/WinRAR-Extractor/frmExtractor.cs index 16308da..252eec8 100644 --- a/WinRAR-Extractor/frmExtractor.cs +++ b/WinRAR-Extractor/frmExtractor.cs @@ -91,6 +91,30 @@ private void btnRefresh_Click(object sender, EventArgs e) string lastModified_x64 = HttpWebHelper.GetHttpWebData(freeUrl_x64, 3000, null, true); //Console.WriteLine(lastModified_x64); + int lmCheck = Convert.ToInt32(lastModified_x86); + while (lmCheck > 0) + { + if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe", 3000, null, true)) + { + lmCheck--; + lastModified_x86 = lmCheck.ToString(); + continue; + } + break; + } + + lmCheck = Convert.ToInt32(lastModified_x64); + while (lmCheck > 0) + { + if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{lastSCname_x64.Value}sc.exe", 3000, null, true)) + { + lmCheck--; + lastModified_x64 = lmCheck.ToString(); + continue; + } + break; + } + this.labVersion.Text = $"最新版本:[{version}],更新时间:[{lastModified_x86}]-[x86] / [{lastModified_x64}]-[x64] - [简体中文]"; string rrlb_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe"; diff --git a/WinRAR-Generate/WinRAR-Generate.rc b/WinRAR-Generate/WinRAR-Generate.rc index 901ca7b..524bc1f 100644 Binary files a/WinRAR-Generate/WinRAR-Generate.rc and b/WinRAR-Generate/WinRAR-Generate.rc differ diff --git a/WinRAR-Generate/WinRAR-Generate.vcxproj b/WinRAR-Generate/WinRAR-Generate.vcxproj index 805a36f..14a98e8 100644 --- a/WinRAR-Generate/WinRAR-Generate.vcxproj +++ b/WinRAR-Generate/WinRAR-Generate.vcxproj @@ -22,7 +22,7 @@ {E510275F-C4D1-4E4A-922C-9856CF1C8908} Win32Proj WinRARGenerate - 10.0.14393.0 + 10.0.10586.0