[英]Changing the icon of an .exe file in Rust
所以我做了一些研究,發現 Windows 中的 rs.exe 將包含名稱 to_do 和 PATH 的 resources.rs 文件轉換為 ico 到 res。 唯一的問題是在導航到其目錄並運行命令 rs resource.exe 之后。 我收到錯誤 RC1109,我告訴我 rc.exe 找不到路徑。
我究竟做錯了什么? 我應該將resources.rs 文件保存在與rc.exe 相同的文件夾中嗎?
我是否必須以某種方式格式化文件中包含的文本?
一如既往地感謝您的幫助!
您可以在運行cargo build
或cargo run
時使用winres
crate 為 .exe 設置圖標。
將此添加到您的Cargo.toml :
[package]
...
build = "build.rs"
[build-dependencies]
winres = "0.1"
然后在Cargo.toml所在目錄下創建一個build.rs文件,內容如下:
extern crate winres;
fn main() {
if cfg!(target_os = "windows") {
let mut res = winres::WindowsResource::new();
res.set_icon("my_icon.ico"); // Replace this with the filename of your .ico file.
res.compile().unwrap();
}
}
然后,您也必須將 your.ico 文件復制到同一目錄中。 不要忘記更改build.rs中的文件名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.