| 1 |
Windows Manifest Embedding for Rust |
| 2 |
=================================== |
| 3 |
|
| 4 |
The `embed-manifest` crate provides a straightforward way to embed |
| 5 |
a Windows manifest in an executable, whatever the build environment, |
| 6 |
without dependencies on external tools from LLVM or MinGW. |
| 7 |
|
| 8 |
If you need to embed more resources than just a manifest, you may |
| 9 |
find the [winres](https://crates.io/crates/winres) or |
| 10 |
[embed-resource](https://crates.io/crates/embed-resource) |
| 11 |
crates more suitable. They have additional dependencies and setup |
| 12 |
requirements that may make them a little more difficult to use, though. |
| 13 |
|
| 14 |
|
| 15 |
Why use it? |
| 16 |
----------- |
| 17 |
|
| 18 |
The Rust compiler doesn’t add a manifest to a Windows executable, which |
| 19 |
means that it runs with a few compatibility options and settings that |
| 20 |
make it look like the program is running on an older version of Windows. |
| 21 |
By adding an application manifest using this crate, even when cross-compiling: |
| 22 |
|
| 23 |
- 32-bit programs with names that look like installers don’t try to run |
| 24 |
as an administrator. |
| 25 |
- 32-bit programs aren’t shown a virtualised view of the filesystem and |
| 26 |
registry. |
| 27 |
- Many non-Unicode APIs accept UTF-8 strings, the same as Rust uses. |
| 28 |
- The program sees the real Windows version, not Windows Vista. |
| 29 |
- Built-in message boxes and other UI elements can display without blurring |
| 30 |
on high-DPI monitors. |
| 31 |
- Other features like long path names in APIs can be enabled. |
| 32 |
|
| 33 |
|
| 34 |
Usage |
| 35 |
----- |
| 36 |
|
| 37 |
To embed a default manifest, include this code in a `build.rs` build |
| 38 |
script: |
| 39 |
|
| 40 |
```rust |
| 41 |
use embed_manifest::{embed_manifest, new_manifest}; |
| 42 |
|
| 43 |
fn main() { |
| 44 |
if std::env::var_os("CARGO_CFG_WINDOWS").is_some() { |
| 45 |
embed_manifest(new_manifest("Contoso.Sample")) |
| 46 |
.expect("unable to embed manifest file"); |
| 47 |
} |
| 48 |
println!("cargo:rerun-if-changed=build.rs"); |
| 49 |
} |
| 50 |
``` |
| 51 |
|
| 52 |
See the [crate documentation](https://docs.rs/embed-manifest) for |
| 53 |
information about how to customise the embedded manifest. |
| 54 |
|
| 55 |
|
| 56 |
License |
| 57 |
------- |
| 58 |
|
| 59 |
For the avoidance of doubt, while this crate itself is licensed to |
| 60 |
you under the MIT License, this does not affect the copyright status |
| 61 |
and licensing of your own code when this is used from a Cargo build |
| 62 |
script. |