Skip to content

Commit

Permalink
v1.0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lvtx committed Aug 21, 2022
1 parent c892584 commit 618e552
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 24 deletions.
4 changes: 4 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ C# WinRAR 简体中文-商业版 提取器

#### 更新日志

2022-08-21 发布v1.0.0.3
1. 修复新版x32位程序信息无法获取问题。
2. 修复中文授权信息出现问号问题。

2021-06-20 发布v1.0.0.2
1. 增加最新版本信息独立下载按钮。
2. 修复已知错误。
Expand Down
58 changes: 58 additions & 0 deletions WinRAR-Extractor/HtmlHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace WinRAR_Extractor
{
public class HtmlHelper
{
/// <summary>
/// 使用举例:
/// 获取关键词 GetSingleTagValueByAttr(data, "meta", "name", "Keywords"); data是HTML源代码
/// 获取描述 GetSingleTagValueByAttr(data, "meta", "name", "Discription");
/// 获取跳转 GetSingleTagValueByAttr(data, "meta", "http-equiv", "refresh");
/// </summary>
/// <param name="inputstring"></param>
/// <param name="tagName"></param>
/// <param name="attrname"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetSingleTagValueByAttr(string inputstring, string tagName, string attrname, string key)
{
//string reg2 = $"(?<=meta name=\"keywords\" content=\").*?(?=\")";
string regStr = $"(?<={tagName} {attrname}=\"{key}\" content=\").*?(?=\")";
//string key_words = Regex.Match(inputstring, regStr).Value;

//Regex reg = new Regex("<" + tagName + " [^<>]*>", RegexOptions.IgnoreCase);
Regex reg = new Regex(regStr, RegexOptions.IgnoreCase);
MatchCollection matchs = reg.Matches(inputstring);
string result = string.Empty;
foreach (Match match in matchs)
{
string matchValue = match.Value;
if (!string.IsNullOrEmpty(matchValue))
{
return matchValue;
}
//Regex regValue = new Regex("content=".* "", RegexOptions.IgnoreCase);
//if (matchValue.ToLower().IndexOf(attrname.ToLower() + "="" + key.ToLower() + """) != -1)
//{
// if (regValue.IsMatch(matchValue))
// {
// result = regValue.Match(matchValue).Value;
// if (!string.IsNullOrEmpty(result))
// {
// //result = result.Replace("CONTENT=", "").Replace("content=", "").Replace(""", "");

// }
// }
// return result;
//}
}
return null;
}
}
}
6 changes: 3 additions & 3 deletions WinRAR-Extractor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WinRAR-Extractor")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © 2021 - 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: AssemblyVersion("1.0.0.3")]
[assembly: AssemblyFileVersion("1.0.0.3")]
4 changes: 2 additions & 2 deletions WinRAR-Extractor/frmExtractor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 65 additions & 19 deletions WinRAR-Extractor/frmExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,66 @@ private void btnRefresh_Click(object sender, EventArgs e)
string checkUrl = "https://www.winrar.com.cn/download.htm";
string html = HttpWebHelper.GetHttpWebData(checkUrl, 3000, null);
//Console.WriteLine(html);

int version = 0;
Match white14link = Regex.Match(html,
"(?<=<a href=\"download-).+?(?=(32|64)scp.html\" target=\"_blank\" class=\"white14link\">(32|64)位下载</a>)",
string freeUrl_x86 = string.Empty;
string freeUrl_x64 = string.Empty;

Match white14Link = Regex.Match(html,
"(?<=<a href=\")download-.+?(32|64)scp.html(?=\" target=\"_blank\" class=\"white14link\">(32|64)位下载</a>)",
RegexOptions.Multiline | RegexOptions.Singleline);
while (white14link.Success)
//Console.WriteLine(white14Link.Groups.Count);

while (white14Link.Success)
{
int result = 0;
if (int.TryParse(white14link.Value, out result))
//Console.WriteLine(white14Link.Value);
int result = 0, bit = 0;
Match versionLink = Regex.Match(white14Link.Value, "(?<=download-).+?(?=(32|64)scp.html)");
//Console.WriteLine(versionLink.Value);

if (int.TryParse(versionLink.Value, out result))
{
if (version < result)
if (version <= result)
{
version = result;
//Console.WriteLine(white14link.Value);
Match bitLink = Regex.Match(white14Link.Value, $"(?<=download-{version}).+?(?=scp.html)");
//Console.WriteLine(bitLink.Value);

string downloadUrl = $"https://www.winrar.com.cn/{white14Link.Value}";
//Console.WriteLine(downloadUrl);
string htmld = HttpWebHelper.GetHttpWebData(downloadUrl, 3000, null);
//Console.WriteLine(htmld);

Match downloadLink = Regex.Match(htmld, $"(?<=meta http-equiv=\"refresh\" content=\".+?;url=).*?(?=\")");
//Console.WriteLine(downloadLink.Value);

if (int.TryParse(bitLink.Value, out bit) && bit != 64)
{
freeUrl_x86 = downloadLink.Value;
}
else
{
freeUrl_x64 = downloadLink.Value;
}
}
}
white14link = white14link.NextMatch();
white14Link = white14Link.NextMatch();
}
string freeUrl_x86 = $"https://www.winrar.com.cn/download/wrar{version}scp.exe";

Match lastSCname_x86 = Regex.Match(freeUrl_x86, "(?<=https://www.winrar.com.cn/download/).+?(?=scp.exe)");
string lastModified_x86 = HttpWebHelper.GetHttpWebData(freeUrl_x86, 3000, null, true);
//Console.WriteLine(lastModified_x86);
string freeUrl_x64 = $"https://www.winrar.com.cn/download/winrar-x64-{version}scp.exe";

Match lastSCname_x64 = Regex.Match(freeUrl_x64, "(?<=https://www.winrar.com.cn/download/).+?(?=scp.exe)");
string lastModified_x64 = HttpWebHelper.GetHttpWebData(freeUrl_x64, 3000, null, true);
//Console.WriteLine(lastModified_x64);

this.labVersion.Text = $"最新版本:{version},更新时间:{lastModified_x86} - [简体中文]";
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/wrar{version}sc.exe";
string rrlb_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/winrar-x64-{version}sc.exe";
string wrr_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/wrr/wrar{version}sc.exe";
string wrr_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/wrr/winrar-x64-{version}sc.exe";
string rrlb_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe";
string rrlb_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{lastSCname_x64.Value}sc.exe";
string wrr_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/wrr/{lastSCname_x86.Value}sc.exe";
string wrr_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/wrr/{lastSCname_x64.Value}sc.exe";

this.tbrrlbx86.Text = rrlb_x86;
this.tbrrlbx64.Text = rrlb_x64;
Expand Down Expand Up @@ -102,8 +130,25 @@ private void btnwrrx64_Click(object sender, EventArgs e)

[DllImport("WinRAR-Generate.dll", CharSet = CharSet.Ansi, EntryPoint = "KeyGenerate", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr KeyGenerate(string UserName, string LicenseType);

private void btnGenerate_Click(object sender, EventArgs e)
{
if (tbName.Text.Equals(string.Empty) || tbName.Text == "")
{
MessageBox.Show("请先填写授权用户!", "授权提示");
tbName.Focus();
return;
}
if (tbLicense.Text.Equals(string.Empty) || tbLicense.Text == "")
{
MessageBox.Show("请先填写授权信息!", "授权提示");
tbLicense.Focus();
return;
}

string UserName = tbName.Text;
string LicenseType = tbLicense.Text;

// 点击弹出对话框
SaveFileDialog saveFileDialog = new SaveFileDialog();
// 设置对话框的标题
Expand All @@ -118,8 +163,9 @@ private void btnGenerate_Click(object sender, EventArgs e)
//展示对话框
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string rarreg = Marshal.PtrToStringAnsi(KeyGenerate(tbName.Text, tbLicense.Text));
StreamWriter sw = new StreamWriter(saveFileDialog.FileName, false, Encoding.ASCII);
string rarreg = Marshal.PtrToStringAnsi(KeyGenerate(UserName, LicenseType));
// [2022/08/21] 修复中文字符变问号问题 [Encoding.ASCII => Encoding.Default]
StreamWriter sw = new StreamWriter(saveFileDialog.FileName, false, Encoding.Default);
sw.Write(rarreg);
sw.Flush();
sw.Close();
Expand Down
Binary file modified WinRAR-Generate/WinRAR-Generate.rc
Binary file not shown.

0 comments on commit 618e552

Please sign in to comment.