Skip to content

Commit bf764e8

Browse files
authored
feat(utils): expose windows_version function (#4534)
1 parent 3125a5a commit bf764e8

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

.changes/expose-windows-version.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch
3+
---
4+
5+
Expose `platform::windows_version` function.

core/tauri-utils/src/platform.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
198198
}
199199

200200
#[cfg(windows)]
201-
pub use windows_platform::is_windows_7;
201+
pub use windows_platform::{is_windows_7, windows_version};
202202

203203
#[cfg(windows)]
204204
mod windows_platform {
@@ -212,7 +212,7 @@ mod windows_platform {
212212

213213
/// Checks if we're running on Windows 7.
214214
pub fn is_windows_7() -> bool {
215-
if let Some(v) = get_windows_ver() {
215+
if let Some(v) = windows_version() {
216216
// windows 7 is 6.1
217217
if v.0 == 6 && v.1 == 1 {
218218
return true;
@@ -240,8 +240,8 @@ mod windows_platform {
240240
};
241241
}
242242

243-
/// Returns a tuple of (major, minor, buildnumber)
244-
fn get_windows_ver() -> Option<(u32, u32, u32)> {
243+
/// Returns a tuple of (major, minor, buildnumber) for the Windows version.
244+
pub fn windows_version() -> Option<(u32, u32, u32)> {
245245
type RtlGetVersion = unsafe extern "system" fn(*mut OSVERSIONINFOW) -> i32;
246246
let handle = get_function!("ntdll.dll", RtlGetVersion);
247247
if let Some(rtl_get_version) = handle {

0 commit comments

Comments
 (0)