diff --git a/src-tauri/src/native/aumid.rs b/src-tauri/src/native/aumid.rs index e00ad4b..5494f72 100644 --- a/src-tauri/src/native/aumid.rs +++ b/src-tauri/src/native/aumid.rs @@ -24,14 +24,18 @@ pub const APP_USER_MODEL_ID: &str = "LotusGuild.LotusChat"; #[cfg(target_os = "windows")] pub fn ensure_app_user_model_id(_app: &AppHandle) { use std::os::windows::ffi::OsStrExt; - use windows::core::{Interface, GUID, HSTRING, PCWSTR}; + use windows::core::{Interface, HSTRING, PCWSTR}; + // PKEY_AppUserModel_ID lives in EnhancedStorage (same module as jumplist's + // PKEY_Title), NOT PropertiesSystem — use the ready-made constant rather than + // hand-rolling the PROPERTYKEY. + use windows::Win32::Storage::EnhancedStorage::PKEY_AppUserModel_ID; use windows::Win32::System::Com::{ CoCreateInstance, CoInitializeEx, CoUninitialize, IPersistFile, StructuredStorage::PROPVARIANT, CLSCTX_INPROC_SERVER, COINIT_APARTMENTTHREADED, }; use windows::Win32::UI::Shell::{ - PropertiesSystem::{IPropertyStore, PROPERTYKEY}, - IShellLinkW, SetCurrentProcessExplicitAppUserModelID, ShellLink, + PropertiesSystem::IPropertyStore, IShellLinkW, SetCurrentProcessExplicitAppUserModelID, + ShellLink, }; // 1. Advertise the AUMID for this process (must happen before any toast fires). @@ -68,13 +72,6 @@ pub fn ensure_app_user_model_id(_app: &AppHandle) { .chain(std::iter::once(0)) .collect(); - // PKEY_AppUserModel_ID = {9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, pid 5. - // Constructed inline so we don't depend on the const's crate module path. - const PKEY_APP_USER_MODEL_ID: PROPERTYKEY = PROPERTYKEY { - fmtid: GUID::from_u128(0x9F4C2855_9F79_4B39_A8D0_E1D42DE1D5F3), - pid: 5, - }; - // STA apartment for the shell link objects, mirroring jumplist.rs. All COM // interfaces are dropped before CoUninitialize. let hr = unsafe { CoInitializeEx(None, COINIT_APARTMENTTHREADED) }; @@ -88,13 +85,12 @@ pub fn ensure_app_user_model_id(_app: &AppHandle) { // like PKEY_Title in jumplist.rs). let store: IPropertyStore = link.cast()?; let value = PROPVARIANT::from(APP_USER_MODEL_ID); - store.SetValue(&PKEY_APP_USER_MODEL_ID, &value)?; + store.SetValue(&PKEY_AppUserModel_ID, &value)?; store.Commit()?; // Persist the .lnk to the Start-Menu Programs folder. let persist: IPersistFile = link.cast()?; - // fremember is a Win32 BOOL (not bool); `.into()` uses From. - persist.Save(PCWSTR(lnk_wide.as_ptr()), true.into())?; + persist.Save(PCWSTR(lnk_wide.as_ptr()), true)?; Ok(()) } })();