I am developing an application using an additional monitor (Wacom tablet). I need to determine where it is located, but the DisplayName, which I compile from java code, always displays 0, Display 1, etc ... I tried using a little C ++ to display the system:
void DumpDevice(const DISPLAY_DEVICE& dd, size_t nSpaceCount)
{
printf("%*sDevice Name: %s\n", nSpaceCount, "", dd.DeviceName);
printf("%*sDevice String: %s\n", nSpaceCount, "", dd.DeviceString);
printf("%*sState Flags: %x\n", nSpaceCount, "", dd.StateFlags);
printf("%*sDeviceID: %s\n", nSpaceCount, "", dd.DeviceID);
printf("%*sDeviceKey: ...%s\n\n", nSpaceCount, "", dd.DeviceKey + 42);
}
int main()
{
DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
DWORD deviceNum = 0;
while (EnumDisplayDevices(NULL, deviceNum, &dd, 0)){
DumpDevice(dd, 0);
DISPLAY_DEVICE newdd = { 0 };
newdd.cb = sizeof(DISPLAY_DEVICE);
DWORD monitorNum = 0;
while (EnumDisplayDevices(dd.DeviceName, monitorNum, &newdd, 0))
{
DumpDevice(newdd, 4);
monitorNum++;
}
puts("");
deviceNum++;
}
system("pause");
return 0;
}
(I get this code from another answer here when the stack overflows, but I don’t remember the page linking to it).
The output, in any case, is really not useful:
Device Name: \
Device String: I
State Flags: 5
DeviceID: P
DeviceKey: ...\
Device Name: \
Device String: G
State Flags: 3
DeviceID: M
DeviceKey: ...\
Device Name: \
Device String: I
State Flags: 1
DeviceID: P
DeviceKey: ...\
Device Name: \
Device String: G
State Flags: 3
DeviceID: M
DeviceKey: ...\
Device Name: \
Device String: I
State Flags: 1
DeviceID: P
DeviceKey: ...\
Device Name: \
Device String: G
State Flags: 3
DeviceID: M
DeviceKey: ...\
Device Name: \
Device String: I
State Flags: 8000000
DeviceID: P
DeviceKey: ...\
Device Name: \
Device String: I
State Flags: 0
DeviceID: P
DeviceKey: ...\
Device Name: \
Device String: I
State Flags: 0
DeviceID: P
DeviceKey: ...\
Any hint to solve this problem?
Edit: all this is necessary in a Java application, I use C ++ to create a simple wrapper and use JNI to call my wrapper. If there is a better way to do this without switching from C ++, better.