Skip to content

[May be bug] Incorrect Method to Get Monitor ID on Windows #1102

Open
@thep0y

Description

@thep0y

pub fn name(&self) -> Option<String> {
let monitor_info = get_monitor_info(self.hmonitor()).unwrap();
Some(util::wchar_ptr_to_string(PCWSTR::from_raw(
monitor_info.szDevice.as_ptr(),
)))
}
#[inline]
pub fn native_identifier(&self) -> String {
self.name().unwrap()
}

It is incorrect to directly use the Monitor Name as the Monitor ID. This ID cannot be used when managing the monitor. For example, the current method returns an ID like "\\\\.\\DISPLAY1", but the actual ID for the first monitor should be \\\\?\\DISPLAY#RTD0004#5&5bd6e4c&0&UID261#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}. This ID needs to be obtained through a more complex method.

I'm working on a project to set wallpapers for monitors. The wallpaper can only be successfully configured with the correct monitor ID, and the interface used to set the wallpaper is IDesktopWallpaper::SetWallpaper.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions