Skip to content

Commit

Permalink
Upgrade to windows 0.39.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick888 committed Jul 23, 2022
1 parent e2ffe0d commit 2b57ef5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ xml-rs = "0.8.4"
strum = { version = "0.22.0", features = ["derive"] }

[target.'cfg(target_env = "msvc")'.dependencies.windows]
version = "0.38.0"
version = "0.39.0"
features = [
"Win32_Foundation",
"Foundation_Collections",
Expand All @@ -29,9 +29,8 @@ features = [
]

[target.'cfg(target_env = "gnu")'.dependencies.windows]
version = "0.38.0"
version = "0.39.0"
features = [
"alloc",
"Win32_Foundation",
"Foundation_Collections",
"Win32_System_SystemInformation",
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Toast {
}
};

toast_xml.LoadXml(HSTRING::from(format!(
toast_xml.LoadXml(&HSTRING::from(format!(
"<toast {} {}>
<visual>
<binding template=\"{}\">
Expand All @@ -321,14 +321,14 @@ impl Toast {
)))?;

// Create the toast
ToastNotification::CreateToastNotification(toast_xml)
ToastNotification::CreateToastNotification(&toast_xml)
}

/// Display the toast on the screen
pub fn show(&self) -> windows::core::Result<()> {
let toast_template = self.create_template()?;

let toast_notifier = ToastNotificationManager::CreateToastNotifierWithId(HSTRING::from(&self.app_id))?;
let toast_notifier = ToastNotificationManager::CreateToastNotifierWithId(&HSTRING::from(&self.app_id))?;

// Show the toast.
let result = toast_notifier.Show(&toast_template);
Expand Down
8 changes: 6 additions & 2 deletions src/windows_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ mod internal {
// but we know it's in ntdll which will always be present at runtime.
#[cfg(target_env = "gnu")]
mod internal {
use windows::core::PCSTR;
use windows::Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress};

#[allow(non_upper_case_globals)]
static mut CacheRtlGetNtVersionNumbers: Option<unsafe extern "system" fn() -> isize> = None;

#[allow(non_snake_case)]
pub unsafe fn RtlGetNtVersionNumbers(major: *mut u32, minor: *mut u32, build: *mut u32) {
const NTDLL: PCSTR = PCSTR::from_raw("ntdll.dll".as_bytes().as_ptr());
const RTL_GET_VERSION_NUMBERS: PCSTR = PCSTR::from_raw("RtlGetNtVersionNumbers".as_bytes().as_ptr());

if CacheRtlGetNtVersionNumbers.is_none() {
if let Ok(handle) = GetModuleHandleA("ntdll.dll") {
CacheRtlGetNtVersionNumbers = GetProcAddress(handle, "RtlGetNtVersionNumbers");
if let Ok(handle) = GetModuleHandleA(NTDLL) {
CacheRtlGetNtVersionNumbers = GetProcAddress(handle, RTL_GET_VERSION_NUMBERS);
}
}

Expand Down

0 comments on commit 2b57ef5

Please sign in to comment.