Get Windows version in a batch file

It’s much easier (and faster) to get this information by only parsing the output of ver: @echo off setlocal for /f “tokens=4-5 delims=. ” %%i in (‘ver’) do set VERSION=%%i.%%j if “%version%” == “10.0” echo Windows 10 if “%version%” == “6.3” echo Windows 8.1 if “%version%” == “6.2” echo Windows 8. if “%version%” == “6.1” … Read more

How to automatically download C++ dependencies in a cross platform way + CMake?

In CMake you can use file(DOWNLOAD URL PATH) to download a file, combine this with custom commands to download and unpack: set(MY_URL “http://…”) set(MY_DOWNLOAD_PATH “path/to/download/to”) set(MY_EXTRACTED_FILE “path/to/extracted/file”) if (NOT EXISTS “${MY_DOWNLOAD_PATH}”) file(DOWNLOAD “${MY_URL}” “${MY_DOWNLOAD_PATH}”) endif() add_custom_command( OUTPUT “${MY_EXTRACTED_FILE}” COMMAND command to unpack DEPENDS “${MY_DOWNLOAD_PATH}”) Your target should depend on the output from the custom command, … Read more

WPF applications stop responding to touches after adding or removing tablet devices

Your operating system will ultimately crash, bog down due to resource usage, or otherwise corrupt memory if the hardware device is repeatedly connected and disconnected. Suggest you change the WPF desktop application to do nothing until the user connects the tablet and clicks on a button in the WPF desktop application to “Enable Tablet” support. … Read more

Preventing MSYS ‘bash’ from killing processes that trap ^C

I had the exact same problem – I had written a program with a SIGINT/SIGTERM handler. That handler did clean-up work which sometimes took awhile. When I ran the program from within msys bash, ctrl-c would cause my SIGINT handler to fire, but it would not finish – the program was terminated (“from the outside”, … Read more