Name of the connected monitor

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.

+4
1

ANSII charset, ( SirDarius ):

Device Name: \\.\DISPLAY1
Device String: Intel(R) HD Graphics Family
State Flags: 5
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0000

    Device Name: \\.\DISPLAY1\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\AUO133D\{4d36e96e-e325-11ce-bfc1-08002be10318}\0003
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0003


Device Name: \\.\DISPLAY2
Device String: Intel(R) HD Graphics Family
State Flags: 1
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0001

    Device Name: \\.\DISPLAY2\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\DELA0B9\{4d36e96e-e325-11ce-bfc1-08002be10318}\0004
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0004


Device Name: \\.\DISPLAY3
Device String: Intel(R) HD Graphics Family
State Flags: 1
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0002

    Device Name: \\.\DISPLAY3\Monitor0
    Device String: Generic PnP Monitor
    State Flags: 3
    DeviceID: MONITOR\WAC1039\{4d36e96e-e325-11ce-bfc1-08002be10318}\0006
    DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0006


Device Name: \\.\DISPLAY4
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0003


Device Name: \\.\DISPLAY5
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0004


Device Name: \\.\DISPLAY6
Device String: Intel(R) HD Graphics Family
State Flags: 8000000
DeviceID: PCI\VEN_8086&DEV_0A16&SUBSYS_05CB1028&REV_0B
DeviceKey: ...\Control\Video\{80DB7D25-0399-49FD-A13A-F5FEAD8FCC0B}\0005

, PnP!

+2

Source: https://habr.com/ru/post/1623248/


All Articles