From 7d14daf1d5fce4d09471a3abe2aca49cf7680816 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Wed, 2 Dec 2020 05:25:19 -0500 Subject: embed version info into assemblies check app versions against lib, lib against driver add an 'about' dialog which displays version details, accessible from menu refactor error handling + add check for negative offset --- converter/AssemblyInfo.cpp | 12 +++++ converter/converter.cpp | 28 +++++++--- converter/converter.rc | 100 ++++++++++++++++++++++++++++++++++++ converter/converter.vcxproj | 13 +++++ converter/converter.vcxproj.filters | 13 +++++ converter/resource.h | 14 +++++ 6 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 converter/AssemblyInfo.cpp create mode 100644 converter/converter.rc create mode 100644 converter/resource.h (limited to 'converter') diff --git a/converter/AssemblyInfo.cpp b/converter/AssemblyInfo.cpp new file mode 100644 index 0000000..cbe3aec --- /dev/null +++ b/converter/AssemblyInfo.cpp @@ -0,0 +1,12 @@ +#include + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +[assembly:AssemblyVersion(RA_VER_STRING)] + +[assembly:ComVisible(false)] ; +[assembly:CLSCompliantAttribute(true)] ; diff --git a/converter/converter.cpp b/converter/converter.cpp index af2699b..230e1be 100644 --- a/converter/converter.cpp +++ b/converter/converter.cpp @@ -192,7 +192,7 @@ bool try_convert(const ia_settings_t& ia_settings) { auto errors = DriverInterop::GetSettingsErrors(new_settings); if (!errors->Empty()) { - Console::WriteLine("Bad settings: " + errors->x->ToArray()[0]); + Console::WriteLine("Bad settings: {0}", errors); return false; } @@ -208,8 +208,26 @@ bool try_convert(const ia_settings_t& ia_settings) { return true; } +public ref struct ASSEMBLY { + static initonly Version^ VERSION = ASSEMBLY::typeid->Assembly->GetName()->Version; +}; + int main() { + auto close_prompt = [] { + std::cout << "Press any key to close this window . . ." << std::endl; + _getwch(); + std::exit(0); + }; + + try { + VersionHelper::ValidateAndGetDriverVersion(ASSEMBLY::VERSION); + } + catch (VersionException^ ex) { + Console::WriteLine(ex->Message); + close_prompt(); + } + std::optional opt_path; if (fs::exists(IA_SETTINGS_NAME)) { @@ -235,11 +253,8 @@ int main() if (!try_convert(parse_ia_settings(opt_path.value()))) std::cout << "Unable to convert settings.\n"; } - catch (DriverNotInstalledException^) { - Console::WriteLine("\nDriver is not installed."); - } catch (Exception^ e) { - Console::WriteLine("\nError: " + e->ToString()); + Console::WriteLine("\nError: {0}", e); } catch (const std::exception& e) { std::cout << "Error: " << e.what() << '\n'; @@ -251,6 +266,5 @@ int main() "Then run this program to generate the equivalent Raw Accel settings.\n"; } - std::cout << "Press any key to close this window . . ." << std::endl; - _getwch(); + close_prompt(); } diff --git a/converter/converter.rc b/converter/converter.rc new file mode 100644 index 0000000..94bc8b5 --- /dev/null +++ b/converter/converter.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "InterAccel -> RawAccel settings file converter" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "converter.exe" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/converter/converter.vcxproj b/converter/converter.vcxproj index 2bc5080..049dec7 100644 --- a/converter/converter.vcxproj +++ b/converter/converter.vcxproj @@ -67,6 +67,9 @@ Console DebugFull + + $(SolutionDir)/common; + @@ -89,8 +92,12 @@ copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" + + $(SolutionDir)/common; + + @@ -103,6 +110,12 @@ ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + diff --git a/converter/converter.vcxproj.filters b/converter/converter.vcxproj.filters index 954dbfa..f1ad70a 100644 --- a/converter/converter.vcxproj.filters +++ b/converter/converter.vcxproj.filters @@ -18,5 +18,18 @@ Source Files + + Source Files + + + + + Header Files + + + + + Resource Files + \ No newline at end of file diff --git a/converter/resource.h b/converter/resource.h new file mode 100644 index 0000000..a2c7ba8 --- /dev/null +++ b/converter/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by converter.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3