pouët.net

Go to bottom

Resolving monitor name in Windows (w/D3D)

category: code [glöplog]
So I've been looking to get the monitor driver description name on screen instead of it's lousy device ID (\\.\DISPLAY1), which I get now..

Code: // Get name. D3DADAPTER_IDENTIFIER9 d3dID; d3d9.Get().GetAdapterIdentifier(iAdapter, 0, &d3dID); dispAd.name = d3dID.Description; // Add monitor ID to display adapter name. FIX_ME // Not happy with this yet! HMONITOR hMonitor = d3d9.Get().GetAdapterMonitor(iAdapter); MONITORINFOEXA monInfoEx; monInfoEx.cbSize = sizeof(MONITORINFOEXA); if (GetMonitorInfoA(hMonitor, &monInfoEx)) { dispAd.name = dispAd.name + " on: " + monInfoEx.szDevice; } else TPB_ASSERT(0); // Mute?


This was my first hunch but as said, that doesn't give me what I'm looking for. Anyone who has pulled that string out of somewhere before? Otherwise I'll continue my manhunt.
added on the 2011-07-27 08:41:04 by superplek superplek
have you tried debugging the monInfoEx structure? :)
Please post the answer if you find it. I'm sick and tired of having the lame device ID as the string in my config-dialog as well... ;)
added on the 2011-07-27 10:08:30 by kusma kusma
OK, there's at least SOME relevant info here...
added on the 2011-07-27 10:11:46 by kusma kusma
WMI is the way to go for most of the stuff you need...
added on the 2011-07-27 10:32:22 by prost prost
Rasmus: I think I gave it a proper look back when I wrote this. Ill fix and post the answer. Thanks guys.
added on the 2011-07-27 11:00:33 by superplek superplek
WMI is teh cancer but indeed has a lot of info can can't get any other way...
added on the 2011-07-27 12:30:24 by raer raer
You can pass the device string from the MONITORINFOEX structure to EnumDisplayDevices() - that will give you more info. Sadly the friendly name member of the DISPLAY_DEVICE struct it fills out always reads "Plug and Play monitor" if no specific monitor driver is installed - as is the case on most computers. Doesn't help too much :(
added on the 2011-07-27 12:55:17 by kb_ kb_
Well kb your option is at least better than what I have now, but I'm gonna check if WMI is workable. If so I'll supply a neatly encapsulated function to do it.
added on the 2011-07-27 13:13:18 by superplek superplek
I found it usually rather convenient to just append the current monitor desktop resolutions.
added on the 2011-07-27 13:29:46 by Gargaj Gargaj
Gargaj: I used to have 4 monitors, 3 of which was using the same resolution. It might be useful for compo-organizers, but I doubt it's very common for regular users to have multiple monitors with a different resolution.
added on the 2011-07-27 14:04:47 by kusma kusma
A standard CPP WMI (+ fallback a-la KB) query is coming up, that is if it works -- coding/testing it.
added on the 2011-07-27 14:08:27 by superplek superplek
kusma: I wouldn't know, but then if you have two screens of the same resolution, common sense would dictate it's the same model as well, in which case monitor name won't help you much either, I suppose.
added on the 2011-07-27 14:21:44 by Gargaj Gargaj
Gargaj: Good point. Yeah, the three of them were indeed of the same model (one was of a different revision, but I'm not sure if that would show). Perhaps something like using the monitor the dialog box itself is located on is a better visual clue to the user?
added on the 2011-07-27 14:26:11 by kusma kusma
It's still a bit of a moot point if you have 1 display head running 4 identical monitors, I'll give you that. It is possible to determine if a monitor is active (i.e switched into a mode) and probably to check if it is primary, secondary, tertiary. I'll see how far I will take this.
added on the 2011-07-27 14:26:38 by superplek superplek
Well, there's also the method the "Identify" button uses in Windows.
added on the 2011-07-27 14:31:00 by Gargaj Gargaj
Elaborate...
added on the 2011-07-27 14:36:29 by superplek superplek
plek: write the monitor number on each of them.
added on the 2011-07-27 14:39:08 by kusma kusma
kb: It seems like I can't pull much more information from WMI either if no specific driver is installed. But there is lots of other info!
added on the 2011-07-27 14:59:58 by superplek superplek
plek: you know, draw big fuckoff number on each monitor :D
added on the 2011-07-27 15:03:25 by Gargaj Gargaj
kusma: Well I can't find much through Win32_DesktopMonitor or any of the underlying classes. Where would I get a monitor number? Still unclear to me..
added on the 2011-07-27 15:04:40 by superplek superplek
yeah I've seen it but where the hell does that number come from ;)
added on the 2011-07-27 15:05:01 by superplek superplek
second parameter of EnumDisplayDevices?
added on the 2011-07-27 15:10:13 by Gargaj Gargaj
Sorry, didn't look at that function yet, first wrote the WMI stuff. Going into that now.
added on the 2011-07-27 15:13:51 by superplek superplek
superplek: I'm sorry, I'm currently at work so I can't look at it. I'm busy recompiling Linux kernels and whatnot.
added on the 2011-07-27 15:17:08 by kusma kusma

login

Go to top