I was making an application for Night Light using Python. I'm using windows API for use of Gamma Ramp to accomplish my task. I used EnumDisplayDevicesW from user32.dll to get the information and number of displays connected to my PC.
I have only one monitor connected to my desktop, but the output is giving information of two monitors.
Here's my code. I'm using Python and accessing WinAPI through ctypes module.
import ctypes
from ctypes import wintypes
class DISPLAY_DEVICEW(ctypes.Structure):
_fields_ = [
('cb', wintypes.DWORD),
('DeviceName', wintypes.WCHAR * 32),
('DeviceString', wintypes.WCHAR * 128),
('StateFlags', wintypes.DWORD),
('DeviceID', wintypes.WCHAR * 128),
('DeviceKey', wintypes.WCHAR * 128)
]
if __name__ == '__main__':
EnumDisplayDevices = ctypes.windll.user32.EnumDisplayDevicesW # get the function address
EnumDisplayDevices.restype = ctypes.c_bool # set return type to BOOL
displays = [] # to store display information
i = 0 # iteration variable for 'iDevNum'
while True:
INFO = DISPLAY_DEVICEW() # struct object
INFO.cb = ctypes.sizeof(INFO) # setting 'cnSize' prior to calling 'EnumDisplayDevicesW'
if not EnumDisplayDevices(None, i, ctypes.byref(INFO), 0):
break # break as soon as False is returned by 'EnumDisplayDevices'
displays.append(INFO) # append information to the list
i += 1
# display information in a sequential form
for x in displays:
print('DeviceName:\t\t', x.DeviceName)
print("DeviceString:\t", x.DeviceString)
print("StateFlags:\t\t", x.StateFlags)
print("DeviceID:\t\t", x.DeviceID)
print("DeviceKey:\t\t", x.DeviceKey)
print(), print()
And the output returned by the code is as follows:-
DeviceName: \\.\DISPLAY1
DeviceString: Intel(R) HD Graphics 510
StateFlags: 5
DeviceID: PCI\VEN_8086&DEV_1902&SUBSYS_D0001458&REV_06
DeviceKey: \Registry\Machine\System\CurrentControlSet\Control\Video\{C31A4E45-2A30-11EB-953B-92862920CE33}\0000
DeviceName: \\.\DISPLAY2
DeviceString: Intel(R) HD Graphics 510
StateFlags: 0
DeviceID: PCI\VEN_8086&DEV_1902&SUBSYS_D0001458&REV_06
DeviceKey: \Registry\Machine\System\CurrentControlSet\Control\Video\{C31A4E45-2A30-11EB-953B-92862920CE33}\0001
As far as I know, the first one, i.e, \\.\DISPLAY1 is mine one, but why there's a need for a second one??
I own a Desktop PC with standard Samsung monitor.
Any help will be very helpful. Thanks in advance!