diff --git a/device/scanner.rc b/device/scanner.rc index 5d34081..d965968 100644 --- a/device/scanner.rc +++ b/device/scanner.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,1015,2022,7061 - PRODUCTVERSION 4,1015,2022,7061 + FILEVERSION 4,1015,2022,7081 + PRODUCTVERSION 4,1015,2022,7081 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "Äþ²¨»ª¸ßÐÅÏ¢¿Æ¼¼ÓÐÏÞ¹«Ë¾" VALUE "FileDescription", "»ª¸ßɨÃèÒÇÓ¦ÓóÌÐò" - VALUE "FileVersion", "4.1015.2022.7061" + VALUE "FileVersion", "4.1015.2022.7081" VALUE "InternalName", "scanner.dll" VALUE "LegalCopyright", "Copyright (C) 2022" VALUE "OriginalFilename", "scanner.dll" VALUE "ProductName", "HUAGOScan" - VALUE "ProductVersion", "4.1015.2022.7061" + VALUE "ProductVersion", "4.1015.2022.7081" END END BLOCK "VarFileInfo" diff --git a/device/scanner.vcxproj b/device/scanner.vcxproj index d37e10c..e5c1b19 100644 --- a/device/scanner.vcxproj +++ b/device/scanner.vcxproj @@ -102,7 +102,7 @@ Level3 true - WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;BACKEND_NAME=hgdriver;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;OEM_NONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true 4996 MultiThreadedDebugDLL @@ -132,7 +132,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$ true true true - WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;BACKEND_NAME=hgdriver;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;HGSCANNER_EXPORT;CUSTOM_USBVIEW;OEM_NONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true 4996 stdcpp17 @@ -313,10 +313,9 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$ + - - - + diff --git a/device/scanner.vcxproj.filters b/device/scanner.vcxproj.filters index 36f6393..3ab1e17 100644 --- a/device/scanner.vcxproj.filters +++ b/device/scanner.vcxproj.filters @@ -185,15 +185,6 @@ - - 头文件 - - - 头文件 - - - 头文件 - image @@ -395,6 +386,12 @@ 头文件 + + 头文件 + + + 头文件 + diff --git a/sane/sane.rc b/sane/sane.rc index 52642cc..b3f9326 100644 --- a/sane/sane.rc +++ b/sane/sane.rc @@ -248,8 +248,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,1015,2022,7061 - PRODUCTVERSION 4,1015,2022,7061 + FILEVERSION 4,1015,2022,7081 + PRODUCTVERSION 4,1015,2022,7081 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -266,12 +266,12 @@ BEGIN BEGIN VALUE "CompanyName", "Äþ²¨»ª¸ßÐÅÏ¢¿Æ¼¼ÓÐÏÞ¹«Ë¾" VALUE "FileDescription", "»ª¸ßɨÃèÒÇÓ¦ÓóÌÐò" - VALUE "FileVersion", "4.1015.2022.7061" + VALUE "FileVersion", "4.1015.2022.7081" VALUE "InternalName", "sane.dll" VALUE "LegalCopyright", "Copyright (C) 2022" VALUE "OriginalFilename", "sane.dll" VALUE "ProductName", "HUAGOScan" - VALUE "ProductVersion", "4.1015.2022.7061" + VALUE "ProductVersion", "4.1015.2022.7081" END END BLOCK "VarFileInfo" diff --git a/sane/sane.vcxproj b/sane/sane.vcxproj index 1b32e88..39c9a7f 100644 --- a/sane/sane.vcxproj +++ b/sane/sane.vcxproj @@ -103,7 +103,7 @@ Level3 true - BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;OEM_NONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 4996 @@ -128,7 +128,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$ true true true - BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + BACKEND_NAME=hgsane;TWPP_IS_DS;EXPORT_SANE_API;WIN32;OEM_NONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 4996 diff --git a/sln/Release/hgsetver.exe b/sln/Release/hgsetver.exe index d0428d8..5acd423 100644 Binary files a/sln/Release/hgsetver.exe and b/sln/Release/hgsetver.exe differ diff --git a/sln/hgsetver/hgsetver.cpp b/sln/hgsetver/hgsetver.cpp index aebe056..61fadd0 100644 --- a/sln/hgsetver/hgsetver.cpp +++ b/sln/hgsetver/hgsetver.cpp @@ -568,6 +568,33 @@ namespace rc } } while (end); } + static bool change_file(const wchar_t* file, oem o, bool(__stdcall* modify)(std::wstring& cont, oem o)) + { + bom bm = BOM_UTF8; + std::wstring cont(load_file(file, &bm)); + bool ret = modify(cont, o); + + if (ret) + { + std::string bomstr(""); + + if (bm == BOM_UNICODE) + coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bomstr); + else if (bm == BOM_UTF8) + { + std::string utf8(""); + + coding_util::unicode_2_utf8(cont.c_str(), got_str, &utf8); + coding_util::bom::from_utf8(utf8.c_str(), utf8.length(), got_str, &bomstr); + } + else + coding_util::unicode_2_ansi(cont.c_str(), got_str, &bomstr); + file_util::save_2_file(bomstr.c_str(), bomstr.length(), file); + } + + return ret; + } + bool set_rc_ver(const wchar_t* file, int v_1, int v_2, int v_3, int v_4, const wchar_t* company_name, const wchar_t* short_company_name, const wchar_t* vender) { bom bm = BOM_UTF8; @@ -702,6 +729,138 @@ namespace rc return true; } + bool change_vcxproj_predefine(const wchar_t* file, oem o) + { + bom bm = BOM_UTF8; + std::wstring cont(load_file(file, &bm)), backend(L""), lead(L"BACKEND_NAME="); + size_t pos = cont.find(lead), end = 0; + + //if (pos == std::wstring::npos) + // return false; + if (cont.length() < 1000) + return false; + + if (o == OEM_HANWANG) + backend = L"hw"; + else if (o == OEM_LISICHENG) + backend = L"lsc"; + else + backend = L"hg"; + backend += L"sane"; + + while (pos != std::wstring::npos) + { + pos += lead.length(); + end = pos; + while (cont[end] != L';' && cont[end] != L'<') + end++; + cont.replace(pos, end - pos, backend); + pos += backend.length(); + pos = cont.find(lead, pos); + } + + pos = cont.find(L"OEM_"); + while (pos != std::wstring::npos) + { + end = pos + 4; + while (cont[end] != L';' && cont[end] != L'<') + end++; + if (from_str(cont.substr(pos, end - pos).c_str()) != OEM_NOT) + { + cont.replace(pos, end - pos, oem_str(o)); + end = pos + oem_str(o).length(); + } + pos = cont.find(L"OEM_", end); + } + + std::string bomstr(""); + if (bm == BOM_UNICODE) + coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bomstr); + else if (bm == BOM_UTF8) + { + std::string utf8(""); + + coding_util::unicode_2_utf8(cont.c_str(), got_str, &utf8); + coding_util::bom::from_utf8(utf8.c_str(), utf8.length(), got_str, &bomstr); + } + else + coding_util::unicode_2_ansi(cont.c_str(), got_str, &bomstr); + file_util::save_2_file(bomstr.c_str(), bomstr.length(), file); + + return true; + } + + bool __stdcall change_sane_def(std::wstring& cont, oem o) + { + std::wstring backend(L"sane_"), prev(L"_hgsane_"); + + if (o == OEM_HANWANG) + backend.insert(0, L"_hw"); + else if (o == OEM_LISICHENG) + backend.insert(0, L"_lsc"); + else + backend.insert(0, L"_hg"); + + if (cont.find(backend) != std::wstring::npos) + return true; + + if (cont.find(prev) == std::wstring::npos) + { + prev = L"_hwsane_"; + if (cont.find(prev) == std::wstring::npos) + { + prev = L"_lscsane_"; + if (cont.find(prev) == std::wstring::npos) + return false; + } + } + + size_t pos = cont.find(prev); + while (pos != std::wstring::npos) + { + cont.replace(pos, prev.length(), backend); + pos += backend.length(); + pos = cont.find(prev, pos); + } + + return true; + } + bool __stdcall change_device_def(std::wstring& cont, oem o) + { + std::wstring backend(L"_scanner_"), prev(L"hg_scanner_"); + + if (o == OEM_HANWANG) + backend.insert(0, L"hw"); + else if (o == OEM_LISICHENG) + backend.insert(0, L"lsc"); + else + backend.insert(0, L"hg"); + + if (cont.find(backend) != std::wstring::npos) + return true; + + if (cont.find(prev) == std::wstring::npos) + { + prev = L"hw_scanner_"; + if (cont.find(prev) == std::wstring::npos) + { + prev = L"lsc_scanner_"; + if (cont.find(prev) == std::wstring::npos) + return false; + } + } + + size_t pos = cont.find(prev); + while (pos != std::wstring::npos) + { + cont.replace(pos, prev.length(), backend); + pos += backend.length(); + pos = cont.find(prev, pos); + } + + return true; + } + }; static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main) @@ -762,20 +921,40 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main coding_util::unicode_2_ansi(unic.c_str(), got_str, &cont); file_util::save_2_file(cont.c_str(), cont.length(), file); - std::wstring cn(L""), scn(L""), vendor(L""), base(file), rcf(L""); + std::wstring cn(L""), scn(L""), vs(L""), base(file), rcf(L""); STR_PARENT_FOLDER(base); - if (rc::get_version_from_file(file, &main, &sub, &build, &patch, &cn, &scn, &vendor)) + if (rc::get_version_from_file(file, &main, &sub, &build, &patch, &cn, &scn, &vs)) { + rcf = base + L"\\..\\sane\\sane.vcxproj"; + STR_SIMPLIFY_PATH(rcf); + if(!rc::change_vcxproj_predefine(rcf.c_str(), vendor)) + std::wcout << "change predefines failed: " << rcf.c_str() << std::endl; + rcf = base + L"\\..\\sane\\sane.rc"; STR_SIMPLIFY_PATH(rcf); - if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vendor.c_str())) + if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vs.c_str())) std::wcout << "change version failed: " << rcf.c_str() << std::endl; + rcf = base + L"\\..\\sane\\sane.def"; + STR_SIMPLIFY_PATH(rcf); + if(!rc::change_file(rcf.c_str(), vendor, rc::change_sane_def)) + std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl; + + rcf = base + L"\\..\\device\\scanner.vcxproj"; + STR_SIMPLIFY_PATH(rcf); + if(!rc::change_vcxproj_predefine(rcf.c_str(), vendor)) + std::wcout << "change predefines failed: " << rcf.c_str() << std::endl; + rcf = base + L"\\..\\device\\scanner.rc"; STR_SIMPLIFY_PATH(rcf); - if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vendor.c_str())) + if (!rc::set_rc_ver(rcf.c_str(), main, sub, build, patch, cn.c_str(), scn.c_str(), vs.c_str())) std::wcout << "change version failed: " << rcf.c_str() << std::endl; + + rcf = base + L"\\..\\device\\device.def"; + STR_SIMPLIFY_PATH(rcf); + if(!rc::change_file(rcf.c_str(), vendor, rc::change_device_def)) + std::wcout << "change exporting-definition failed: " << rcf.c_str() << std::endl; } else { diff --git a/twain/brand.h b/twain/brand.h index 2bf0c12..4c8e5e6 100644 --- a/twain/brand.h +++ b/twain/brand.h @@ -8,7 +8,7 @@ #define VERSION_MAIN 4 #define VERSION_SUB 1015 #define VERSION_BUILD 2022 -#define VERSION_PATCH 7061 +#define VERSION_PATCH 7081 #define TO_STR(a) #a #define TO_VER_STR(vs) TO_STR(v##vs)