Created
November 6, 2025 01:39
-
-
Save shuantsu/af707846c7f6eba1226e5ec45c688b2b to your computer and use it in GitHub Desktop.
ververust
This file contains hidden or 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
| [package] | |
| name = "ververust" | |
| version = "0.1.0" | |
| edition = "2024" | |
| [dependencies] | |
| win32-version-info = "0.3" | |
| [profile.release] | |
| opt-level = "z" | |
| strip = true | |
| lto = true | |
| panic = "abort" |
This file contains hidden or 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
| use win32_version_info::VersionInfo; | |
| use std::path::Path; | |
| fn get_file_version(path: &Path) -> Result<String, String> { | |
| // 1. Tenta carregar as informações de versão do arquivo | |
| match VersionInfo::from_file(path) { | |
| Ok(info) => { | |
| // 2. Retorna o 'file_version' que corresponde à "Versão do Arquivo" | |
| // (File Version) que é exibida na aba Detalhes do Windows. | |
| Ok(info.file_version) | |
| // Se você quisesse a "Versão do Produto", usaria: | |
| // Ok(info.product_version) | |
| }, | |
| Err(e) => { | |
| // 3. Trata erros | |
| Err(format!("Falha ao ler a versão do arquivo: {}", e)) | |
| } | |
| } | |
| } | |
| fn main() { | |
| // Substitua pelo caminho real do seu arquivo .exe | |
| let exe_path = Path::new("C:\\Program Files\\Git\\git-bash.exe"); | |
| println!("Tentando ler a Versão do Arquivo de: {}", exe_path.display()); | |
| match get_file_version(exe_path) { | |
| Ok(version) => { | |
| println!("\n✅ Versão do Arquivo: **{}**", version); | |
| }, | |
| Err(e) => { | |
| eprintln!("\n❌ Erro: {}", e); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment