Reputation: 649
I'm using https://electronjs.org/docs/api/screen#screengetalldisplays method to get information about monitors. Then this information goes to C++ Application where it tries to match monitor by ID
. The problem is that Electron gives ID
which I can't match to a result of the EnumDisplayDevicesA
method call.
Electron Display ID: 2528732444
C++ EnumDisplayDevicesA values:
DeviceID: "PCI\\VEN_10DE&DEV_1B81&SUBSYS_33011462&REV_A1"
DeviceKey: "\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\{48210CD6-1F3B-11E9-9541-D05099833422}\\0000"
So Electron ID doesn't match any ID's available by EnumDisplayDevicesA
. Is the any possible way to match Electron display to Win API display?
Upvotes: 1
Views: 711
Reputation: 514
The id comes from electron's screen object as you already pointed out. That internally uses Chromium's screen (see the #include "ui/display/screen.h"
. After more digging, I found that the id comes from the method at line 59 of the implementation of display_info.cc. It is just a hash generated from the device name which comes from the os, namely from the MonitorInfoEXA struct.
Maybe you can repeat the hash they do to the name and match it with the id though.
static_cast<int64_t>(base::Hash(base::WideToUTF8(device_name))
where device name is szDevice from this struct.
Upvotes: 4