Re: Second monitor enumeration
- Posted by petelomax Jun 23, 2019
- 991 views
AndyDrummond said...
ddret = w32Func(xEnumDisplayDevicesA, {VOID, 1, ddptr, 1}) -- I also tried NULL where I have VOID
Is this a valid way to call the function??
Don't ever use VOID like that. It is a "junkyard", and will contain whatever crud from who-knows-what. Use NULL instead.
I've not done much with multiple monitors (and gave up on win32lib a looooooooooonnnngg time ago) so I can't go much beyond this, but it's a start:
constant sizeDD = 424, DD_DeviceName = 4, DD_DeviceString = 36, DD_StateFlags = 164, pDD = allocate(sizeDD), EDD_GET_DEVICE_INTERFACE_NAME = 1, user32 = open_dll("user32.dll"), xEnumDisplayDevices = define_c_func(user32,"EnumDisplayDevicesA",{C_PTR,C_DWORD,C_PTR,C_DWORD},C_BOOL) mem_set(pDD,0,sizeDD) poke4(pDD,sizeDD) for iDevNum=0 to 9999 do if not c_func(xEnumDisplayDevices,{NULL,iDevNum,pDD,EDD_GET_DEVICE_INTERFACE_NAME}) then exit end if string device_name = peek_string(pDD+DD_DeviceName) ?device_name atom pDeviceName = allocate_string(device_name) printf(1,"flags:%x\n",peek4u(pDD+DD_StateFlags)) for jDevNum=0 to 9999 do if not c_func(xEnumDisplayDevices,{pDeviceName,jDevNum,pDD,EDD_GET_DEVICE_INTERFACE_NAME}) then exit end if ?peek_string(pDD+DD_DeviceName) ?peek_string(pDD+DD_DeviceString) printf(1,"flags:%x\n",peek4u(pDD+DD_StateFlags)) end for ?"===" end for
I get
"\\\\.\\DISPLAY1" flags:8000005 "\\\\.\\DISPLAY1\\Monitor0" "BenQ GL2450H" flags:3 "===" "\\\\.\\DISPLAY2" flags:8000000 "==="I suspect I do indeed have two adapters but only one physical display device. I don't know what the flags are, and as you say there is no width/height, so... I am probably using EDD_GET_DEVICE_INTERFACE_NAME all wrong to boot.