Created
July 11, 2020 22:03
-
-
Save WeaponMan/152fd45d2c34bc96eaf834b46bf1aa87 to your computer and use it in GitHub Desktop.
Windows Resources version rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | |
<security> | |
<requestedPrivileges> | |
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> | |
</requestedPrivileges> | |
</security> | |
</trustInfo> | |
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(any(windows))] | |
fn main() { | |
use std::path::Path; | |
use std::fs::File; | |
use std::io::Write; | |
let file = "Resources.rc"; | |
let file_path = Path::new(file); | |
let major = env!("CARGO_PKG_VERSION_MAJOR"); | |
let minor = env!("CARGO_PKG_VERSION_MINOR"); | |
let patch = env!("CARGO_PKG_VERSION_PATCH"); | |
let mut src = File::create(&file_path).unwrap(); | |
let new_resource = format!(r#" | |
#define RT_MANIFEST 24 | |
#define APP_VERSION "{}.{}.{}.0" | |
#define APP_VERSION_2 {},{},{},0 | |
1 RT_MANIFEST "app-name.exe.manifest" | |
1 VERSIONINFO | |
FILEVERSION APP_VERSION_2 | |
PRODUCTVERSION APP_VERSION_2 | |
FILEOS 0x4 | |
FILETYPE 0x1 | |
{{ | |
BLOCK "StringFileInfo" | |
{{ | |
BLOCK "000004b0" | |
{{ | |
VALUE "Comments", "" | |
VALUE "CompanyName", "Company ltd" | |
VALUE "FileDescription", "App description" | |
VALUE "FileVersion", APP_VERSION | |
VALUE "InternalName", "app-name.exe" | |
VALUE "LegalCopyright", "Copyright \xA9" | |
VALUE "LegalTrademarks", "" | |
VALUE "OriginalFilename", "app-name.exe" | |
VALUE "ProductName", "App product name" | |
VALUE "ProductVersion", APP_VERSION | |
VALUE "Assembly Version", APP_VERSION | |
}} | |
}} | |
BLOCK "VarFileInfo" | |
{{ | |
VALUE "Translation", 0x0000 0x04B0 | |
}} | |
}} | |
"#, major, minor, patch, major, minor, patch); | |
src.write_all(new_resource.as_bytes()).unwrap(); | |
src.flush().unwrap(); | |
drop(src); | |
embed_resource::compile("Resources.rc"); | |
} | |
#[cfg(not(windows))] | |
fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment