C++ Windows Libaray
The Windows library holds all the C++ tools and utilities the are for use with Microsoft Windows. Each include adds to the CyTools namespace.
#include <windows.h>
#include <iostream> // std::cout
#include <filesystem> // std::filesystem::path, std::filesystem::exists
#include <CyVersion.hpp> // CyTools::VersionInfo
int main(int argc, char* argv[]) {
bool output_help = true;
// output our basic header
std::cout << "CyVersionCmd Demo" << std::endl;
std::cout << "A simple example of CyVersion usage" << std::endl;
std::cout << "Copyright ©2025 by Adrian Hunt. All rights reserved" << std::endl;
std::cout << std::endl;
if (argc == 2) {
// we have been give a single parameter
std::filesystem::path file (argv[1]);
if (std::filesystem::exists(file)) {
// the file exists, lets try getting version info
CyTools::VersionInfo info;
if (info.load(file)) {
// version information loaded successfully
std::cout << "Version information in \"" << file.filename() << "\" is, as such:" << std::endl;
std::cout << std::endl;
std::cout << "Product name: " << info.product_name() << std::endl;
std::cout << "Product version: " << info.product_version() << std::endl;
std::cout << std::endl;
std::cout << "Original filename: " << info.original_filename() << std::endl;
std::cout << "File version: " << info.file_version() << std::endl;
std::cout << "Copyright: " << info.legal_copyright() << std::endl;
std::cout << std::endl;
std::cout << "...they go on, but this is just a demo" << std::endl;
std::cout << std::endl;
output_help = false;
}
else {
// version info load failed
std::cout << "!- Given file does not seem to contain version information -!" << std::endl;
std::cout << std::endl;
}
}
else {
// file does not exist
std::cout << "!- Given file could not be found -!" << std::endl;
std::cout << std::endl;
}
}
if (output_help) {
// output usage information
std::cout << "To use at the command line, type..." << std::endl;
std::cout << std::endl;
std::cout << "CyVersionCmd \"filename\"" << std::endl;
std::cout << std::endl;
std::cout << "...where [filename] is the name (and path) of an" << std::endl;
std::cout << "existing file. Version information will be extracted" << std::endl;
std::cout << "and displayed, when available" << std::endl;
}
std::cout << std::endl << std::endl;
return 0;
}
CyVersion
version - 1.0.0a
CyVersion header provides a simple object that uses the Windows API to retrieve version information from binary files, such as executables (exe) and dynamic libraries (dll). The version object has methods to easily query version data for standard content, such as version number, build flags, copyright, and description. It also supports multi-language version tables and custom field retrieval.
Downloads
| CyVersion.zip | CyVersion header. |
| CyVersion-examples.zip | Source code demonstrating use of CyVersion. |