Skip to content

Commit

Permalink
feat(utils): expose windows_version function (#4534)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jun 30, 2022
1 parent 3125a5a commit bf764e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/expose-windows-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-utils": patch
---

Expose `platform::windows_version` function.
8 changes: 4 additions & 4 deletions core/tauri-utils/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bf764e8

Please sign in to comment.