feat(utils): expose windows_version function (#4534)

This commit is contained in:
Lucas Fernandes Nogueira 2022-06-30 10:38:01 -03:00 committed by GitHub
parent 3125a5a383
commit bf764e83e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-utils": patch
---
Expose `platform::windows_version` function.

View File

@ -198,7 +198,7 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
}
#[cfg(windows)]
pub use windows_platform::is_windows_7;
pub use windows_platform::{is_windows_7, windows_version};
#[cfg(windows)]
mod windows_platform {
@ -212,7 +212,7 @@ mod windows_platform {
/// Checks if we're running on Windows 7.
pub fn is_windows_7() -> bool {
if let Some(v) = get_windows_ver() {
if let Some(v) = windows_version() {
// windows 7 is 6.1
if v.0 == 6 && v.1 == 1 {
return true;
@ -240,8 +240,8 @@ mod windows_platform {
};
}
/// Returns a tuple of (major, minor, buildnumber)
fn get_windows_ver() -> Option<(u32, u32, u32)> {
/// Returns a tuple of (major, minor, buildnumber) for the Windows version.
pub fn windows_version() -> Option<(u32, u32, u32)> {
type RtlGetVersion = unsafe extern "system" fn(*mut OSVERSIONINFOW) -> i32;
let handle = get_function!("ntdll.dll", RtlGetVersion);
if let Some(rtl_get_version) = handle {