Crate winres[][src]

Expand description

Rust Windows resource helper

This crate implements a simple generator for Windows resource (.rc) files for use with either Microsoft rc.exe resource compiler or with GNU windres.exe

The WindowsResorce::compile() method is intended to be used from a build script and needs environment variables from cargo to be set. It not only compiles the resource but directs cargo to link the resource compiler’s output.


if cfg!(target_os = "windows") {
    let mut res = winres::WindowsResource::new();
       .set("InternalName", "TEST.EXE")
       // manually set version
       .set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001000000000000);


We try to guess some sensible default values from Cargo’s build time environement variables This is described in WindowsResource::new(). Furthermore we have to know where to find the resource compiler for the MSVC Toolkit. This can be done by looking up a registry key but for MinGW this has to be done manually.

The following paths are the hardcoded defaults: MSVC the last registry key at HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots, for MinGW we try our luck by simply using the %PATH% environment variable.

Note that the toolkit bitness as to match the one from the current Rust compiler. If you are using Rust GNU 64-bit you have to use MinGW64. For MSVC this is simpler as (recent) Windows SDK always installs both versions on a 64-bit system.



Version info field names