winres-edit

Crate for modification of windows resources.

Crates.io Crates.io

Overview

This crate allows you to load and modify Windows resources inside of .exe and .res files. This crate currently does not support actual resource data destructuring with exception of Version Strings (VSVERSIONINFO), which is useful to modify application manifests. Loaded resources are available as raw Vec<u8> data, useful to modify bitmaps and icons.

Example

```rust let mut resources = Resources::new(&Path::new("myfile.exe")); resources.load().expect("Unable to load resources"); resources.open().expect("Unable to open resource file for updates");

resources.find(resourcetype::ICON,Id::Integer(1)) .expect("unable to find main icon") .replace(icondata)? .update()?;

let version: [u16;4] = [0,1,0,0]; resources.getversioninfo()?.expect("Unable to get version info") .setfileversion(&version) .setproductversion(&version) .insertstrings( &[ ("ProductName","My Product") ("FileDescription","My File") ] ) .removestring("SomeExistingString") .update()?;

resources.close(); ```

Icons

This crate works well in conjunction with the ico crate that can be used to load/store external .ico files as well as load .png files and encode them into windows-compatible resource format.

Example

rust let iconfile = std::fs::File::open("myicon.ico").unwrap(); let icon_dir = ico::IconDir::read(iconfile).unwrap(); let target_icon = icon_dir .entries() .iter() .find(|&e| e.width() == 256) .expect("can't find 256x256 icon"); let icon_data = target_icon.data();

This crate also works well in conjunction with the image crate that can interact with the ico crate to load, resize and and store custom icons within resource files.