From 288ad366417a73265971faae0bed4c55362eab77 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Tue, 19 Dec 2023 14:40:29 +0800 Subject: [PATCH] no format! --- src-tauri/monitor/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src-tauri/monitor/src/lib.rs b/src-tauri/monitor/src/lib.rs index c9fce1a..d59f11f 100644 --- a/src-tauri/monitor/src/lib.rs +++ b/src-tauri/monitor/src/lib.rs @@ -281,9 +281,10 @@ impl Monitor { id } - fn get_wmi_instance(&self, class: &str) -> Result> { - let query = format!("SELECT * FROM {class} WHERE InstanceName=\""); - let mut query: Vec<_> = query.encode_utf16().collect(); + fn get_wmi_instance(&self, class: &[u16]) -> Result> { + let mut query = Vec::from(L!("SELECT * FROM ")); + query.extend_from_slice(class); + query.extend(L!(" WHERE InstanceName=\"")); let instance_name = self.get_wmi_instance_name(); query.extend(instance_name.into_iter().flat_map(|ch| match ch { L!('\\') => [ch, ch].into_iter().take(2), @@ -295,7 +296,7 @@ impl Monitor { } pub fn get_user_friendly_name(&self) -> Result> { - let Some(instance) = self.get_wmi_instance("WmiMonitorID")? else { + let Some(instance) = self.get_wmi_instance(&L!("WmiMonitorID"))? else { return Ok(None); }; let mut variant: mem::MaybeUninit = mem::MaybeUninit::uninit();