winres_edit/lib.rs
1/*!
2 [<img alt="github" src="https://img.shields.io/badge/github-aspectron/winres--edit-8da0cb?style=for-the-badge&labelColor=555555&color=8da0cb&logo=github" height="20">](https://github.com/aspectron/winres-edit)
3[<img alt="crates.io" src="https://img.shields.io/crates/v/winres-edit.svg?maxAge=2592000&style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/winres-edit)
4[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-winres--edit-56c2a5?maxAge=2592000&style=for-the-badge&logo=docs.rs" height="20">](https://docs.rs/winres-edit)
5<img alt="license" src="https://img.shields.io/crates/l/winres-edit.svg?maxAge=2592000&color=6ac&style=for-the-badge&logoColor=fff" height="20">
6
7This crate allows you to load and modify Windows resources inside of `.exe`
8and `.res` files. This crate currently does not support actual resource
9data destructuring with exception of Version Strings (VS_VERSIONINFO),
10which is useful to modify application manifests. Loaded resources are
11available as raw `Vec<u8>` data, useful to modify bitmaps and icons.
12
13Please note that all operations performed on the opened resource file are accumulated and are then "flushed" to the file when the file is closed
14using the `close()` function. This is due to the behavior of the underlying Win32 API ([UpdateResource](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-updateresourcea)) functionality used by this crate.
15
16### Example
17
18#### Load and update a resource
19```rust
20let mut resources = Resources::new(&Path::new("myfile.exe"));
21resources.load().expect("Unable to load resources");
22resources.open().expect("Unable to open resource file for updates");
23
24resources.find(resource_type::ICON,Id::Integer(1))
25 .expect("unable to find main icon")
26 .replace(icon_data)?
27 .update()?;
28
29let version: [u16;4] = [0,1,0,0];
30resources.get_version_info()?.expect("Unable to get version info")
31 .set_file_version(&version)
32 .set_product_version(&version)
33 .insert_strings(
34 &[
35 ("ProductName","My Product")
36 ("FileDescription","My File")
37 ]
38 )
39 .remove_string("SomeExistingString")
40 .update()?;
41
42resources.close();
43```
44
45#### Create a new resource
46
47```rust
48let res = Resource::new(
49 &resources,
50 resource_type::ICON.into(),
51 Id::Integer(14).into(),
52 1033,
53 target_icon.data(),
54);
55res.update()?;
56*/
57
58mod error;
59mod id;
60mod resources;
61mod result;
62mod utils;
63mod version;
64
65pub use error::*;
66pub use id::*;
67pub use resources::*;
68pub use version::*;