mirror of
https://github.com/Nezumi-2711/winrar-keygen.git
synced 2026-09-22 05:41:48 +00:00
🔧 Fixed Windows version output and non-windows encoding option
This commit is contained in:
+5
-1
@@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
set(APP_VERSION "4.1.0.0")
|
set(APP_VERSION "4.2.0")
|
||||||
|
|
||||||
add_executable(winrar-keygen
|
add_executable(winrar-keygen
|
||||||
_tmain.cpp
|
_tmain.cpp
|
||||||
@@ -19,6 +19,10 @@ add_executable(winrar-keygen
|
|||||||
WinRarKeygen.hpp
|
WinRarKeygen.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_sources(winrar-keygen PRIVATE winrar-keygen.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(winrar-keygen PRIVATE
|
target_compile_definitions(winrar-keygen PRIVATE
|
||||||
APP_VERSION="${APP_VERSION}"
|
APP_VERSION="${APP_VERSION}"
|
||||||
)
|
)
|
||||||
|
|||||||
+4
-41
@@ -21,12 +21,11 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma comment(lib, "Version.lib")
|
|
||||||
#pragma comment(lib, "winhttp.lib")
|
#pragma comment(lib, "winhttp.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef APP_VERSION
|
#ifndef APP_VERSION
|
||||||
#define APP_VERSION "4.1.0.0"
|
#define APP_VERSION "4.2.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -237,7 +236,7 @@ void ShowHelp(const std::string& version) {
|
|||||||
std::cout << " winrar-keygen -v | --version\n";
|
std::cout << " winrar-keygen -v | --version\n";
|
||||||
std::cout << " winrar-keygen -h | --help\n\n";
|
std::cout << " winrar-keygen -h | --help\n\n";
|
||||||
std::cout << "Options:\n";
|
std::cout << "Options:\n";
|
||||||
std::cout << " -e, --encoding <enc> utf8 (default), ascii\n";
|
std::cout << " -e, --encoding <enc> utf8 (default), ascii, ansi\n";
|
||||||
std::cout << " -o, --output <file> Output file (default: rarreg.key)\n";
|
std::cout << " -o, --output <file> Output file (default: rarreg.key)\n";
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
std::cout << " -a, --activate Write to ~/Library/Application Support/com.rarlab.WinRAR/rarreg.key\n";
|
std::cout << " -a, --activate Write to ~/Library/Application Support/com.rarlab.WinRAR/rarreg.key\n";
|
||||||
@@ -256,44 +255,9 @@ void ShowHelp(const std::string& version) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
std::wstring GetExecutableVersion() {
|
|
||||||
wchar_t exePath[MAX_PATH] = {};
|
|
||||||
DWORD pathLen = GetModuleFileNameW(nullptr, exePath, MAX_PATH);
|
|
||||||
if (pathLen == 0) {
|
|
||||||
return L"unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD handle = 0;
|
|
||||||
DWORD versionSize = GetFileVersionInfoSizeW(exePath, &handle);
|
|
||||||
if (versionSize == 0) {
|
|
||||||
return L"unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<BYTE> versionData(versionSize);
|
|
||||||
if (!GetFileVersionInfoW(exePath, 0, versionSize, versionData.data())) {
|
|
||||||
return L"unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
VS_FIXEDFILEINFO* fixedInfo = nullptr;
|
|
||||||
UINT len = 0;
|
|
||||||
if (!VerQueryValueW(versionData.data(), L"\\",
|
|
||||||
reinterpret_cast<LPVOID*>(&fixedInfo),
|
|
||||||
&len) ||
|
|
||||||
fixedInfo == nullptr) {
|
|
||||||
return L"unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::to_wstring(HIWORD(fixedInfo->dwFileVersionMS)) + L"." +
|
|
||||||
std::to_wstring(LOWORD(fixedInfo->dwFileVersionMS)) + L"." +
|
|
||||||
std::to_wstring(HIWORD(fixedInfo->dwFileVersionLS)) + L"." +
|
|
||||||
std::to_wstring(LOWORD(fixedInfo->dwFileVersionLS));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
std::string GetAppVersion() {
|
std::string GetAppVersion() {
|
||||||
return APP_VERSION;
|
return APP_VERSION;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void PrintRegisterInfo(const WinRarKeygen<WinRarConfig>::RegisterInfo& Info,
|
void PrintRegisterInfo(const WinRarKeygen<WinRarConfig>::RegisterInfo& Info,
|
||||||
@@ -577,7 +541,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring version = GetExecutableVersion();
|
std::wstring version = Utf8ToWide(GetAppVersion());
|
||||||
std::string versionUtf8 = WideToUtf8(version);
|
std::string versionUtf8 = WideToUtf8(version);
|
||||||
|
|
||||||
if (opts.showVersion) {
|
if (opts.showVersion) {
|
||||||
@@ -801,8 +765,7 @@ int main(int argc, char* argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* encName = (opts.encoding == Encoding::UTF8) ? "UTF-8" :
|
const char* encName = (opts.encoding == Encoding::ASCII) ? "ASCII" : "UTF-8";
|
||||||
(opts.encoding == Encoding::ANSI) ? "ANSI" : "ASCII";
|
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
PrintRegisterInfo(Info, displayUser, displayLicense);
|
PrintRegisterInfo(Info, displayUser, displayLicense);
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "winrar-keygen",
|
"name": "winrar-keygen",
|
||||||
"version": "4.1.0.0",
|
"version": "4.2.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"gmp"
|
"gmp"
|
||||||
]
|
]
|
||||||
|
|||||||
+4
-4
@@ -51,8 +51,8 @@ END
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,1,0,0
|
FILEVERSION 4,2,0,0
|
||||||
PRODUCTVERSION 4,1,0,0
|
PRODUCTVERSION 4,2,0,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@@ -69,12 +69,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "WinRAR Keygen"
|
VALUE "CompanyName", "WinRAR Keygen"
|
||||||
VALUE "FileDescription", "WinRAR Key Generation Tool"
|
VALUE "FileDescription", "WinRAR Key Generation Tool"
|
||||||
VALUE "FileVersion", "4.1.0.0"
|
VALUE "FileVersion", "4.2.0"
|
||||||
VALUE "InternalName", "winrar-keygen.exe"
|
VALUE "InternalName", "winrar-keygen.exe"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2021 Bitcookies"
|
VALUE "LegalCopyright", "Copyright (C) 2021 Bitcookies"
|
||||||
VALUE "OriginalFilename", "winrar-keygen.exe"
|
VALUE "OriginalFilename", "winrar-keygen.exe"
|
||||||
VALUE "ProductName", "WinRAR Keygen"
|
VALUE "ProductName", "WinRAR Keygen"
|
||||||
VALUE "ProductVersion", "4.1.0.0"
|
VALUE "ProductVersion", "4.2.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|||||||
Reference in New Issue
Block a user