Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thep0y opened this issue Mar 24, 2025 · 0 comments
Open

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

thep0y opened this issue Mar 24, 2025 · 0 comments
Labels
platform: Windows status: needs triage This issue or pull request needs to be investigated type: bug

Comments

@thep0y
Copy link
Contributor

thep0y commented Mar 24, 2025

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.

@FabianLars FabianLars added type: bug platform: Windows status: needs triage This issue or pull request needs to be investigated labels Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Windows status: needs triage This issue or pull request needs to be investigated type: bug
Projects
None yet
Development

No branches or pull requests

2 participants