From 8479d6e768cfc9454f8fff7be4c02d5d1467aabf Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 3 Jul 2026 10:54:14 -0400 Subject: [PATCH] fix(native): correct PKEY_AppUserModel_ID import (D6 CI build) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows CI failed: PROPERTYKEY is not in Win32::UI::Shell::PropertiesSystem. Use the ready-made PKEY_AppUserModel_ID constant from Win32::Storage::Enhanced Storage (same module jumplist.rs uses for PKEY_Title, feature already enabled) instead of hand-rolling the PROPERTYKEY — drops the GUID::from_u128 dependency. Also simplify IPersistFile::Save's fremember arg (it's bool, not BOOL). All windows-crate symbols now verified against windows-docs-rs (PKEY_AppUser Model_ID / IPersistFile::Save / SetCurrentProcessExplicitAppUserModelID / CreateToastNotifierWithId). Co-Authored-By: Claude Opus 4.8 --- src-tauri/src/native/aumid.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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(()) } })();