# how to get a display is configured to span/extended mode?

This topic is 1555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to retrieve the display mode it is being configured in the OS.

Suppose, when a system has graphic card (any vendor) which supports connecting multi-displays. I'm able query the no. of monitors being connected when display settings configured to extended mode. But, for Span/Duplicate modes, always returns only 1 monitor being connected.

Is there a way to identify

1. no. of monitors being connected regardless of the mode it is being configured? or
2. no. of monitors being attached to the primary display for span/duplicate mode? or
3. what type of mode the display is being configured?

I'm using the below code to identify the display count:

// I need to get the address of a few multi-monitor functions
//
HMODULE user32 = GetModuleHandle ("User32.DLL");
typedef BOOL WINAPI tEnumDisplayDevices (void*, DWORD, DISPLAY_DEVICE*, DWORD);
tEnumDisplayDevices* fEnumDisplayDevices = (tEnumDisplayDevices*) GetProcAddress (user32, "EnumDisplayDevicesA");
if (fEnumDisplayDevices == NULL) return false;

/*int fResult;
fResult = GetSystemMetrics(SM_CMONITORS);*/

// count the number of monitors attached to the system
//
int numMirrorDevices = 0, numMonitorsAttached = 0, numMonitorsTotal = 0;
DISPLAY_DEVICE dd;	dd.cb = sizeof(dd);
for (DWORD dev=0;  fEnumDisplayDevices (NULL, dev, &dd, 0);  ++dev)
{
if (dd.StateFlags & DISPLAY_DEVICE_ACTIVE)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is active. Flags: " << dd.StateFlags);
}
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is primary. Flags: " << dd.StateFlags);
}
if (dd.StateFlags & DISPLAY_DEVICE_REMOVABLE)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is removable. Flags: " << dd.StateFlags);
}
if (dd.StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is VGA. Flags: " << dd.StateFlags);
}
if (dd.StateFlags & DISPLAY_DEVICE_MODESPRUNED)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is more dsiplay modes. Flags: " << dd.StateFlags);
}
if (dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is a mirroring driver device. Flags: " << dd.StateFlags);
numMirrorDevices++;
continue;
}
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is attached to the desktop. Flags: " << dd.StateFlags);
numMonitorsAttached++;
}
else
{
LOG_INFO (funcName << ": Device: " << dd.DeviceName << " is not attached. Flags: " << dd.StateFlags);
}
numMonitorsTotal++;
}

LOG_INFO (funcName << ": " << numMonitorsTotal << " monitors detected, " << numMonitorsAttached
<< " attached to the desktop, mirroring devices: " << numMirrorDevices);


and the output for this code as follows:

when 3 displays are connected (for a QUAD output PC) in Individual/Extended mode i'm getting the below output:

Device: \\.\DISPLAY1 is active. Flags: 5

Device: \\.\DISPLAY1 is primary. Flags: 5
Device: \\.\DISPLAY1 is attached to the desktop. Flags: 5
Device: \\.\DISPLAY2 is active. Flags: 1
Device: \\.\DISPLAY2 is attached to the desktop. Flags: 1
Device: \\.\DISPLAY3 is active. Flags: 1
Device: \\.\DISPLAY3 is attached to the desktop. Flags: 1
Device: \\.\DISPLAY4 is not attached. Flags: 0
Device: \\.\DISPLAYV1 is a mirroring driver device. Flags: 8
Device: \\.\DISPLAYV2 is a mirroring driver device. Flags: 8
4 monitors detected, 3 attached to the desktop, mirroring devices: 2

when the same 3 displays are connected (for a QUAD output PC) in Span/Stretch/Duplicate mode i'm getting below output:

Device: \\.\DISPLAY1 is active. Flags: 5

Device: \\.\DISPLAY1 is primary. Flags: 5
Device: \\.\DISPLAY1 is attached to the desktop. Flags: 5
Device: \\.\DISPLAY2 is not attached. Flags: 0
Device: \\.\DISPLAY3 is not attached. Flags: 0
Device: \\.\DISPLAY4 is not attached. Flags: 0
Device: \\.\DISPLAYV1 is a mirroring driver device. Flags: 8
Device: \\.\DISPLAYV2 is a mirroring driver device. Flags: 8
4 monitors detected, 1 attached to the desktop, mirroring devices: 2

Please let me know if you need any further information.

##### Share on other sites

It is a bit too late to dig in my code and i do not actually know how/if it handles ~stretch modes - but it should (at least it is meant to). Have to check that tomorrow.

However, my code is intended to enumerate all displays and their actual modes (from EDID data: http://en.wikipedia.org/wiki/Extended_display_identification_data#EDID_1.3_data_format ) i use EDD_GET_DEVICE_INTERFACE_NAME for enumeration.

Interface names should be on a per monitor basis - ie. physical monitors instead of logical ones (i doubt the graphics card is faking a EDID response in hardware for stretch modes).

edit: My graphics card does not seem to use your terminology - so i am not sure what any of the stretch options you mentioned actually mean. I use two monitors as one desktop (both on same graphics device - so, stuff can overlap both monitors). No problems detecting the monitors and their desktop coordinates / etc / etc.

edit2: Ha, i thought i remembered a mode that stretched the windows task bar over both screens making windows think it is one monitor. And it seems stretch indeed refer to graphics card faking a single monitor. Google did spit out this in regards to stretch: "Most video cards only support span (aka. stretch) mode on Windows XP and earlier.". No wonder i do not see it mentioned anywhere - it is abandoned nowadays. If true then the only way to know the actual monitors is ask your graphics card in some vendor specific way.

Edited by tanzanite7

##### Share on other sites

Somehow i need to find-out the way of identifying the each monitor being attached. This is highly required for licensing our players based upon the monitor count.

w.r.t Graphic card way, i doubt is there a common methodology being used for all graphic card vendors? Will analyze more on this. Anyways, thanks for you reply.

##### Share on other sites

Somehow i need to find-out the way of identifying the each monitor being attached. This is highly required for licensing our players based upon the monitor count.

This sounds like a generally bad idea. Even if punishing your paying customers is something you wanted to do, you have no guarantee of monitor-to-player ratio. Maybe one player sets up four monitors to play the game in a massive resolution. Maybe four players window your game, launch four copies, and use four controllers to play on a single monitor (not terribly hard, even if you don't provide the options in the game itself).

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 12
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633723
• Total Posts
3013545
×