Windows - read exe version


Trying to find a way to read metadata around EXE files in Windows. Specifically, how to read version info on a EXE or DLL.

Feel like I’m missing the obvious here.



Programmatically in rust or in general? Because there are many tools to find metadata on binaries on windows. Even though, you could still spawn a process and read the output. Depending on what you are going to look for, there are different tools you may need, for example if you want to check whether a binary is a .NET app, you could use dumpbin if I recall, and some other tools for other metadata. It all depends on what you want to do.


I’m looking for the information you can see when right clicking a file and looking at the details tab on Windows.

I can read the timestamps in std::fs::metadata.

New to Rust, so pretty sure I’m just missing something simple.


Like so:

Most of this can actually be found in std::fs::metadata


This is what I’m trying to figure out how to read in Rust.


Not finding this in std::fs::metadata.


I used the pelite crate to do this. There are a few alternatives, but I found pelite to be the simplest way of doing it with cross-platform support.


Cool and thanks, I’ve got some stuff to learn. :slight_smile:


I don’t think the file version is part of PE metadata. It is instead part of another set of metadata which is embedded as a resource in the EXE or DLL. You will need to call Windows API GetFileVersionInfo to get that. See this StackOverflow question for example code in C++. You can write the equivalent in Rust. For that the winapi crate may come in handy.