Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
no format!
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Dec 19, 2023
1 parent 0c2fc5d commit 288ad36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src-tauri/monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ impl Monitor {
id
}

fn get_wmi_instance(&self, class: &str) -> Result<Option<IWbemClassObject>> {
let query = format!("SELECT * FROM {class} WHERE InstanceName=\"");
let mut query: Vec<_> = query.encode_utf16().collect();
fn get_wmi_instance(&self, class: &[u16]) -> Result<Option<IWbemClassObject>> {
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),
Expand All @@ -295,7 +296,7 @@ impl Monitor {
}

pub fn get_user_friendly_name(&self) -> Result<Option<OsString>> {
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<VARIANT> = mem::MaybeUninit::uninit();
Expand Down

0 comments on commit 288ad36

Please sign in to comment.