I need to get device name of a secondary monitor. However when I simply try to retrieve device name, the output is DISPLAY1, DISPLAYV1
and etc.
However I require the name displayed when we check the screen resolution like the Displayname mentioned here:
Firstly I am not sure from where I can obtain this string. On reading a bit I guess it is the friendlyname
of the device. However I am not sure since on calling EnumDisplaySetting() has been giving me Unhandled Exception: Could not access memory location
when this function is called. So I have not been able to verify what the friendly name is exactly. And I believe that the unhandled exception is caused due to improper allocation of memory to the DISPLAY_DEVICE for driverextra in the DISPLAY_DEVICE. I believe this is because of this:
The function fails if iModeNum is greater than the index of the display device's last graphics mode.
mentioned here
Also I did not understand how much memory needs to be allocated to to
DISPLAY_DEVICE->dmDriverExtra as it has been mention in the same link:
Before calling EnumDisplaySettings, set the dmSize member to sizeof(DEVMODE), and set the dmDriverExtra member to indicate the size, in bytes, of the additional space available to receive private driver data.
So my question is manifold:
1) How much memory needs to be allocated to dmDriverExtra?
2) Is friendlyname the right parameter I need for accessing the name provided in the Display Tab in screen resolution. Or if not what other parameter do I need?
3) Is this unhandled exception caused due to improper memory allocation or is there some other reason for this?
4) Are there any other ways to get access to friendlyname of the secondary monitor?