Need clarification on EnumDisplayDevices Win API; Not enumerating all attached displays

Hi,

I am using?EnumDisplayDevices function call to enumerate all attached
displays to my mobile system (notebook). I’ve 4 monitors connected to
my system including internal flat panel. I am calling the function as
below:

i=0;
while(EnumDisplayDevices(NULL,i,&dispdev[i],false))
{
i++;
}

Problem Statement: It enumerates only first two displays attached to
the system and does not enumerate rest two display device connected to
the system

More Details:

It only enumerates \.\DISPLAY1 and \.\DISPLAY2.

However I am expecting it to enumerate \.\DISPLAY1, \.\DISPLAY2,
\.\DISPLAY3 and \.\DISPLAY4 since I’ve four displays connected.

I am using Windows7 32 bit OS.

Could anybody help me out and clarify on this. Your response is much
appreciated!!!

If you call EnumDisplayDevices with lpDevices set to NULL , it returns back information about the Display Adapter rather than the Monitor.

Please refer to this:
http://msdn.microsoft.com/en-us/library/dd162609(VS.85).aspx

Thanks.
Fizal

Thanks Fizal for your reply!!

I already referred to the MSDN documentation on EnumDisplayDevices. It
clearly says that in order to enumerate all display devices connected
to a display adapter, set lpDevices to NULL and keep on incrementing
iDevNum until EnumDisplayDevices function call fails.

As per this premise I should be getting all 4 displays connected to
the display adapter. However I get only two. Could you pl clarify? Am
i missing anything?

On Tue, Feb 2, 2010 at 10:13 PM, wrote:
> If you call EnumDisplayDevices with lpDevices set to NULL , it returns back information about the Display Adapter rather than the Monitor.
>
> Please refer to this:
> http://msdn.microsoft.com/en-us/library/dd162609(VS.85).aspx
>
> Thanks.
> Fizal
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Vishal Sharma wrote:

I already referred to the MSDN documentation on EnumDisplayDevices. It
clearly says that in order to enumerate all display devices connected
to a display adapter, set lpDevices to NULL and keep on incrementing
iDevNum until EnumDisplayDevices function call fails.

As per this premise I should be getting all 4 displays connected to
the display adapter. However I get only two. Could you pl clarify? Am
i missing anything?

Yes, you are. You are missing Fizal’s point. The word “display” is
overloaded. You are interpreting “display” to mean “monitor”, whereas
in Windows terms, “display” often means “graphics chip”.

You might have two graphics chips, each of which happens to be driving
two monitors. Or perhaps one chip is driving one monitor, and one chip
is driving three monitors. Either case would match your results. By
specifying NULL for lpDevice, you are learning about the graphics
chips. The remarks in the MSDN article talk about this exactly, in the
paragraph that starts “To query all monitor devices associated with an
adapter…”


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Fizal and Tim,

Thank you very much for your quick inputs!!

i=0;
while(EnumDisplayDevices(NULL,i,&dispdev[i],false))
{
i++;
}

after executing the above piece of code I get \.\DISPLAY1 and \.\DISPLAY2

further to this i executed below code and was able to get all 4
monitors which were attached as Monitor0, Monitor1, Monitor2 and
Monitor3. :slight_smile:

i=0;
while(EnumDisplayDevices(\.\DISPLAY1,i,&dispdev[i],false)) // dummy code
{
i++;
}

Thanks again guys!!! for your help.

On Wed, Feb 3, 2010 at 12:28 AM, Tim Roberts wrote:
> Vishal Sharma wrote:
>> I already referred to the MSDN documentation on EnumDisplayDevices. It
>> clearly says that in order to enumerate all display devices connected
>> to a display adapter, set ?lpDevices to NULL and keep on incrementing
>> iDevNum until ?EnumDisplayDevices function call fails.
>>
>> As per this premise I should be getting all 4 displays connected to
>> the display adapter. However I get only two. Could you pl clarify? Am
>> i missing anything?
>>
>
> Yes, you are. ?You are missing Fizal’s point. ?The word “display” is
> overloaded. ?You are interpreting “display” to mean “monitor”, whereas
> in Windows terms, “display” often means “graphics chip”.
>
> You might have two graphics chips, each of which happens to be driving
> two monitors. ?Or perhaps one chip is driving one monitor, and one chip
> is driving three monitors. ?Either case would match your results. ?By
> specifying NULL for lpDevice, you are learning about the graphics
> chips. ?The remarks in the MSDN article talk about this exactly, in the
> paragraph that starts “To query all monitor devices associated with an
> adapter…”
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>